Les Lab | Piano duet with a simple robot! @LesLaboratory | Uploaded 4 years ago | Updated 1 hour ago
Raspberry Pi zero and a single Servo driven by pin 18 plays C2 on a keyboard, leaving 2 hands to play the melody!
Hardware is a Raspberry pi zero, and a single SG90 mini servo.
A 'finger' was made from Perspex lined with silicone rubber so it does not damage my Keys!
A more powerful servo would yield better results.
Python code is below This is just slightly modified from the adafruit example here: learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor
# Servo Control
import time
import wiringpi
# use 'GPIO naming'
wiringpi.wiringPiSetupGpio()
# set #18 to be a PWM output
wiringpi.pinMode(18, wiringpi.GPIO.PWM_OUTPUT)
# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
# divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)
delay_period = 0.095
while True:
wiringpi.pwmWrite(18, 90)
time.sleep(delay_period)
wiringpi.pwmWrite(18, 145)
time.sleep(delay_period)
Raspberry Pi zero and a single Servo driven by pin 18 plays C2 on a keyboard, leaving 2 hands to play the melody!
Hardware is a Raspberry pi zero, and a single SG90 mini servo.
A 'finger' was made from Perspex lined with silicone rubber so it does not damage my Keys!
A more powerful servo would yield better results.
Python code is below This is just slightly modified from the adafruit example here: learn.adafruit.com/adafruits-raspberry-pi-lesson-8-using-a-servo-motor
# Servo Control
import time
import wiringpi
# use 'GPIO naming'
wiringpi.wiringPiSetupGpio()
# set #18 to be a PWM output
wiringpi.pinMode(18, wiringpi.GPIO.PWM_OUTPUT)
# set the PWM mode to milliseconds stype
wiringpi.pwmSetMode(wiringpi.GPIO.PWM_MODE_MS)
# divide down clock
wiringpi.pwmSetClock(192)
wiringpi.pwmSetRange(2000)
delay_period = 0.095
while True:
wiringpi.pwmWrite(18, 90)
time.sleep(delay_period)
wiringpi.pwmWrite(18, 145)
time.sleep(delay_period)