Spent a couple of minutes this afternoon playing around with my new SG90 servos I picked up on ebay for a steal. Initially I just wanted to get them talking with an arduino – which although initially looked easy, was a bit of a time vampire. Anyway, trick seems to be code like that attached, and ensuring you have the 5v unplugged until everything has updated and started (no idea why, but seems the loading voltage changes seems to freak the servo out.
int signalPin = 8; //servo signal pin
void setup()
{
pinMode(signalPin, OUTPUT);
}
void loop()
{
for (int i=0; i <= 100; i++) // turn to CCW end, hold 2 seconds
{
digitalWrite(signalPin, HIGH); // control signal high
delayMicroseconds(900); // for 900 uS
digitalWrite(signalPin, LOW); // control signal low
delay(10); // wait 20mS
}
for (int i=0; i <= 50; i++) // turn to CW end, hold 2 seconds
{
digitalWrite(signalPin, HIGH); // control signal high
delayMicroseconds(1100); // for 1500 uS
digitalWrite(signalPin, LOW); // control signal low
delay(1); // wait 20mS
}
}
Some useful reference sites, but be aware that neither of these I could get the code to work, but probably more my issue than the code:
http://principialabs.com/arduino-serial-servo-control/
http://itp.nyu.edu/physcomp/Labs/AnalogIn
Next step, aiming low, I want to get a button in max that will trigger the servo movement:
http://www.cycling74.com/forums/index.php?t=msg&goto=165203
Once I have that, I just need to replicate the action with the 6 other servos, work out how to attach hammers to them all, and then add some sort of step sequencer in max so I can have a 6 note analog drum kit.... that is until my xylophone arrives.













