Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Servo myservo;
- int pos = 0;
- int button1 = D2;
- int servloop = 0;
- void setup() {
- myservo.attach(D1);
- myservo.write(30);
- pinMode(D5, OUTPUT);
- pinMode(button1, INPUT_PULLUP);
- Serial.begin(9600);
- Serial.println(servloop);
- }
- void loop() {
- Serial.println(servloop);
- if (servloop > 0) {
- servloop--;
- }
- if(digitalRead(button1) == LOW){
- while (servloop < 3) {
- myservo.write(0);
- digitalWrite(D5, HIGH);
- delay(1000);
- myservo.write(90);
- digitalWrite(D5, LOW);
- delay(1000);
- servloop ++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement