#include<Servo.h> int pos = 0; Servo servo; void setup() { pinMode(2, INPUT); pinMode(3, INPUT); servo.attach(9); } void loop() { while (digitalRead(2) == HIGH && pos < 180) { pos++; servo.write(pos); delay(10); } while (digitalRead(3) == HIGH && pos > 0) { pos--; servo.write(pos); delay(10); } }
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.