Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define pin 10 // data pin to control servo
- // pulse width (in microseconds)
- int pulsewidth = 2500; // 4 Hz
- // wave period in microseconds
- int period = 20000; // 50 Hz
- void setup() {
- pinMode(pin, OUTPUT);
- }
- void loop() {
- // turn pulse on for pulsewidth duration
- digitalWrite(pin, HIGH);
- delayMicroseconds(pulsewidth);
- // turn pulse off
- digitalWrite(pin, LOW);
- delayMicroseconds(period - pulsewidth);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement