Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo servo;
- const int ServoPin=5;
- const int PotPin=A0;
- int PotVal;
- int angle;
- void setup()
- {
- pinMode (PotPin, INPUT);
- servo.attach (ServoPin);
- Serial.begin (9600);
- }
- void loop()
- {
- PotVal= analogRead (PotPin);
- angle= map (PotVal, 0, 1023, 0, 180);
- angle= constrain (angle, 0, 180);
- servo.write(angle);//servo.write (180)
- delay (5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement