{{{ int potpin = 0; // analog pin used to connect the potentiometer int motorpin=9; //int val; // variable to read the value from the analog pin int sensorval; float val; void setup() { // myservo.attach(7); // attaches the servo on pin 9 to the servo object pinMode (motorpin,OUTPUT); TCCR1A = 0x00; // esto es para setear el timer en uno de los modos de generación de PWM TCCR1B = 0x13; // esto setea el "prescaler" (N), de la siguiente manera: // TCCR1B=0x11 --> N=1; TCCR1B=0x12 -->N=8; TCCR1B=0x13 -->N=64, etc. // N, el famoso "prescaler", es un divisor del clock de la Arduino (16MHz) ICR1 = 3000; // ICR1 es el valor máximo del analogWrite, lo que le llaman el "TOP" } void loop() { sensorval = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) val = map(sensorval, 0, 1023, 75, 360); // scale it to use it with the servo (value between 0 and 180) // myservo.write(val); // sets the servo position according to the scaled value analogWrite (motorpin,val); delay(15); // waits for the servo to get there } }}}