Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Manvi Mittal
- * Servo program
- */
- #include <Servo.h>
- Servo miServito;
- const int PotPin = A0;
- int PotVal;
- int angle;
- void setup()
- {
- // put your setup code here, to run once:
- pinMode (PotPin, INPUT);
- miServito.attach (9);
- Serial.begin (9600);
- }
- void loop()
- {
- // put your main code here, to run repeatedly:
- PotVal = analogRead (PotPin);
- angle = map (PotVal, 0, 1023, 0, 360);
- angle = constrain (angle, 0, 179);
- miServito.write (angle);
- Serial.println (PotPin);
- miServito.write (90);
- delay (300);
- miServito.write (180);
- delay (300);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement