Close

Servo 2 Push Button Code

A project log for Smart Shoes

Features of smart shoes: generates electricity, auto lacing, step counting, etc.

shahid-jariwalaShahid Jariwala 07/16/2018 at 09:020 Comments
#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