Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *Divya Inaganti
- *June 19, 2017
- *Motor and Potentiometer
- */
- #include <Servo.h>
- Servo miServito;
- const int PotPin= A0;
- int PotValue;
- int angle;
- void setup()
- {
- pinMode(PotPin, INPUT);
- miServito.attach(9);
- Serial.begin(9600);
- }
- void loop() {
- {
- PotValue= analogRead(PotPin);
- angle= map(PotValue, 0 , 1023, 0, 179);
- angle= constrain(angle, 0, 179);
- miServito.write(angle);
- miServito.write(0);
- delay (500);
- miServito.write(45);
- delay(500);
- miServito.write(90);
- delay (500);
- miServito.write(135);
- delay(500);
- miServito.write(180);
- delay(500);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement