I just got my Arduino last night and have been playing all day. I have the Seedstudio Relay Shield v.1.3 (darn you, Radio Shack, there exists a version 2), and have successfully programmed the Arduino to operate the relays. Essentially I'm turning the relays on & off with digitalWrites and delays. My primitive code is included below.
My goal is the following:
I have a vintage marionette coin-op game that has 4 buttons; 2 for the hands and 2 for the feet. The operator pushes the buttons to make him dance to the music. The buttons activate 4 separate solenoids. I plan to use the Relay Shield to operate the solenoids without human intervention.
Therefore, the 4 solenoids need to be activated/deactivated somewhat randomly to simulate human operation. The activation time for each would be APPROX. .75 second, with some variation there. When people operate this puppet they usually just flail around and don't keep time with the music, therefore I don't have to sync it with the music. I simply need the hands and feet to go up & down somewhat randomly.
Can someone steer me in the right direction to help me generate this random operation? Thanks for any help. Here's what I've done so far:
void setup() {
// initialize the digital pins as an output.
pinMode(7, OUTPUT);
pinMode(6, OUTPUT);
pinMode(5, OUTPUT);
pinMode(4, OUTPUT);
}
void loop() {
digitalWrite(7, HIGH); // Turns ON Relay on digital pin 7
delay(750); // wait for a period
digitalWrite(6, HIGH); // Turns ON Relay on digital pin 6
delay(750); // wait for a period
digitalWrite(5, HIGH); // Turns ON Relay on digital pin 5
delay(750); // wait for a period
digitalWrite(4, HIGH); // Turns ON Relay on digital pin 4
delay(750); // wait for a period
digitalWrite(4, LOW); // Turns OFF Relay on digital pin 4
delay(750); // wait for a period
digitalWrite(5, LOW); // Turns OFF Relay on digital pin 5
delay(750); // wait for a period
digitalWrite(6, LOW); // Turns OFF Relay on digital pin 6
delay(750); // wait for a period
digitalWrite(7, LOW); // Turns OFF Relay on digital pin 7
delay(750); // wait for a period
}