Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Servo.h>
- Servo myServo ;
- int const Servopin = 9 ;
- int const potentiometerPin = A0 ;
- int potentiometerVal ;
- int angle ;
- void setup()
- {
- myServo.attach(Servopin) ;
- Serial.begin(9600) ;
- }
- void loop()
- {
- potentiometerVal = analogRead(potentiometerPin) ;
- Serial.print("potentiometerVal: ") ;
- Serial.print(potentiometerVal);
- angle = map(potentiometerVal, 0, 1023, 0, 180) ;
- Serial.print(" angle: ");
- Serial.println(angle);
- myServo.write(angle) ;
- delay(500) ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement