Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Jung Min Yean
- * Using the Servo Motor
- * Using the for loop
- * 04/18/19
- */
- #include <Servo.h> // the servo library (every time this is included, you must add an object
- const int servoPin = 3;
- Servo myservito;
- const int PotPin = A0;
- int PotVal = 0;
- int angle = 0;
- void setup()
- {
- myservito.attach(servoPin);
- pinMode(PotPin, INPUT);
- }
- void loop()
- {
- PotVal = analogRead(PotPin);
- angle = map(PotVal,0,1023,0,179);
- myservito.write(angle);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement