Created
September 27, 2014 21:09
-
-
Save radavis/9fb71c670c3f4b276e84 to your computer and use it in GitHub Desktop.
Arduino code to control a servo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GongHitter | |
// by Vikram and Richard | |
#include <Servo.h> | |
int STEP = 5; | |
int DELAY = 500; | |
unsigned long TIME_BETWEEN_HITS = 3600000; // one hour | |
//1000 * 60 * 60 * 24; | |
Servo myservo; // create servo object to control a servo | |
// a maximum of eight servo objects can be created | |
void moveMallet() { | |
// move home | |
myservo.write(90); | |
delay(DELAY); | |
myservo.write(0); | |
delay(250); | |
// strike | |
myservo.write(90); | |
delay(DELAY); | |
} | |
void setup() { | |
myservo.attach(9); // attaches the servo on pin 9 to the servo object | |
} | |
void loop() { | |
moveMallet(); | |
delay(TIME_BETWEEN_HITS); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment