Low Mobility Red-Light-Green-Light

by butlergo in Circuits > Arduino

179 Views, 1 Favorites, 0 Comments

Low Mobility Red-Light-Green-Light

IMG_6627.jpg

The final product is an adjusted version of red-light-green-light for people with limited mobility. Competitors race towards the finish line by pressing a button. This is a 4 player game.

Supplies

  • Arduino Nano RP2040
  • breadboard
  • 3 servo motors
  • 4 button inserts
  • LED dot strand
  • wood and laser cutter
  • alligator clips or soldering materials
  • parchment paper
  • reflective tape
  • wood glue, hot glue, super glue

Write Code

Debounce the first button to change the color of the LEDs. Put the other three buttons in a list and put the three servos in a corresponding list. Calibrate the servos to ensure a full 180° rotation. Code for the servos to move when its respective button is held down. Write an if statement that causes the servo to move back to 0° if its button is held when the light turns red.

Code

# RED LIGHT GREEN LIGHT
import board, pwmio, neopixel, digitalio, time, math
from adafruit_motor import servo
from adafruit_debouncer import Debouncer
from adafruit_led_animation.color import (BLACK,GREEN,RED,YELLOW)
strip = neopixel.NeoPixel(board.A0, 60, brightness = 1, auto_write = True)
button4=digitalio.DigitalInOut(board.D2) button4.switch_to_input(pull=digitalio.Pull.UP) debounced_button=Debouncer(button4)
button_pin=[board.D3, board.D4, board.D5] button=[]
for i in range(3):
button.append(digitalio.DigitalInOut(button_pin[i])) for i in range(3):
button[i].switch_to_input(pull=digitalio.Pull.UP)
# max=2250-2500, min=500-750 pwm1=pwmio.PWMOut(board.A1, frequency=50) pwm2=pwmio.PWMOut(board.A2, frequency=50) pwm3=pwmio.PWMOut(board.A3, frequency=50) pwm=[pwm1,pwm2,pwm3]
motor=[]
for i in range(3):
motor.append(servo.Servo(pwm[i], min_pulse=600, max_pulse=2400))
green_light=True
red_light=False
angle=0
while True:
if green_light:
strip.fill(GREEN) debounced_button.update() if debounced_button.fell:
strip.fill(YELLOW) time.sleep(1) green_light=False
for i in range(3):
if button[i].value==False:
else:
motor[i].angle=angle angle+=1
if angle>180:
angle=0 motor[i].angle=angle time.sleep(0.09)
strip.fill(RED) debounced_button.update() #check status if debounced_button.fell:
strip.fill(GREEN)
green_light=True
for i in range(3):
if button[i].value==False: motor[i].angle=0

Make Attachments Breadboard Compatible

IMG_6581.jpg

Solder male pin connectors to the servos, buttons and LED strand. To account for limited GND pins, solder the four button ground wires to one male pin.

Cut and Prepare Stoplight Panels

IMG_6592.jpg
IMG_6590.jpg

Attach parchment paper to the back of the light holes to diffuse lights. Apply reflective tape to the inside of the other panels to amplify the light.

Attach Lights and Assemble Box

IMG_6609.jpg
IMG_6602.jpg

Glue the LED strand to the back panel. Once box is assembled, insert dividers to prevent light from leaking out the holes for the other colors.

Prepare the Base Structure

IMG_6613.jpg
IMG_6618.jpg

The base structure will display the servos, house the button attachments and hide the hardware and wires. Measure the servos and button attachments and cut their holes into the front panel. Cut a small hole into the top of the box so the LED string can be connected to the breadboard. Cut a larger hole in the top panel, positioned behind the stoplight, so that the hardware is accessible and the battery pack can be changed.