Gear Tower

Plastic toys are great for hacking, modding and improving using Crickit! This box o' gears is fun for about 10 minutes...but when you add motors, sensors and robotics you can make cool interactive art

This example shows how to use the light sensor on the Circuit Playground Express to trigger a motor to rotate. With some audio effects it becomes a Force trainer, or a moving Theremin

Parts List

Adafruit CRICKIT for Circuit Playground Express

PRODUCT ID: 3093
Sometimes we wonder if robotics engineers ever watch movies. If they did, they'd know that making robots into slaves always ends up in a robot rebellion. Why even go down that...
$29.95
IN STOCK

Circuit Playground Express

PRODUCT ID: 3333
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
$24.95
IN STOCK

DC Gearbox Motor - "TT Motor" - 200RPM - 3 to 6VDC

PRODUCT ID: 3777
Perhaps you've been assembling a new robot friend, adding a computer for a brain and other fun personality touches. Now the time has come to let it leave the nest and fly on...
$2.95
OUT OF STOCK

TT Motor Pulley - 36mm Diameter

PRODUCT ID: 3789
Mechanical transmission for the win, this simple plastic pulley can attach to your TT motor to transmit rotation from the motor axle to...somewhere else.This is a very...
$0.75
IN STOCK

Mono Enclosed Speaker - 3W 4 Ohm

PRODUCT ID: 3351
Listen up! This 2.8" x 1.2" speaker is a great addition to any audio project where you need 4 ohm impedance and 3W or less of power. We particularly like...
$3.95
IN STOCK

Wiring

CircuitPython Code For "Force Wave" demo

This project is pretty simple, it looks to see when the light sensor is shaded by your hand and changes the motor from running to off or vice versa.

import time
from busio import I2C
import analogio
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.pwmout import PWMOut
from adafruit_motor import motor
import board

light = analogio.AnalogIn(board.LIGHT)

print("Wave on/off to turn")

# Create seesaw object
i2c = I2C(board.SCL, board.SDA)
seesaw = Seesaw(i2c)

# Create one motor on seesaw PWM pins 22 & 23
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
motor_a.throttle = 0  # motor is stopped

while True:
    print((light.value,))
    # light value drops when a hand passes over
    if light.value < 4000:
        if motor_a.throttle:
            motor_a.throttle = 0
        else:
            motor_a.throttle = 1  # full speed forward

    while light.value < 5000:
        # wait till hand passes over completely
        pass
    time.sleep(0.1)

CircuitPython Code For "Theremin" demo

We can adapt the code above to speed up or slow down the motor based on how far our hand is. The darker the sensor, the faster the motor spins!

import time
from busio import I2C
import analogio
from adafruit_seesaw.seesaw import Seesaw
from adafruit_seesaw.pwmout import PWMOut
from adafruit_motor import motor
import board

light = analogio.AnalogIn(board.LIGHT)


print("Theramin-like turning")

# Create seesaw object
i2c = I2C(board.SCL, board.SDA)
seesaw = Seesaw(i2c)

# Create one motor on seesaw PWM pins 22 & 23
motor_a = motor.DCMotor(PWMOut(seesaw, 22), PWMOut(seesaw, 23))
motor_a.throttle = 0 # motor is stopped

def map_range(x, in_min, in_max, out_min, out_max):
    # Maps a number from one range to another.
    mapped = (x-in_min) * (out_max - out_min) / (in_max-in_min) + out_min
    if out_min <= out_max:
        return max(min(mapped, out_max), out_min)
    return min(max(mapped, out_max), out_min)

while True:
    print((light.value,))
    motor_a.throttle = map_range(light.value, 500, 8000, 1.0, 0)
    time.sleep(0.1)
This guide was first published on May 16, 2018. It was last updated on 2019-04-11 10:08:00 -0400. This page (Gear Tower) was last updated on Apr 19, 2019.