/* NICHSEN "DREHTELLER" * * 06-2019 */#include<Servo.h>Servomyservo;// create servo object to control a servointpotpin=A7;// analog pin used to connect the potentiometerintval;// variable to read the value from the analog pinvoidsetup(){Serial.begin(9600);//Debugingmyservo.attach(3);// attaches the servo on pin 9 to the servo object}voidloop(){val=analogRead(potpin);// reads the value of the potentiometer (value between 0 and 1023)val=map(val,0,1023,84,130);// scale it to use it with the servo in my case Servo stops at 84 and max speed shall be 130 !Serial.println(val);//Debug infomyservo.write(val);// sets the servo position according to the scaled valuedelay(15);// waits for the servo to get there}
Comments