Created
October 4, 2011 02:30
-
-
Save casidiablo/1260775 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Servo.h> | |
Servo servo1; | |
int posicion; | |
void setup() { | |
servo1.attach(3); | |
} | |
void loop() { | |
posicion = 150; // Establecemos el valor de la posicion a 150º | |
posicion = map(posicion, 0, 1023, 0, 179); // Establecemos la relacion entre los grados de giro y el PWM | |
/* Con el mapa de valores anterior establecemos una relacin proporcional */ | |
/* entre el pulso minimo 0 con el grado minimo, 0 tambien y el pulso maximo*/ | |
/* 1023 con el grado maximo, 179*/ | |
servo1.write(posicion); // Escribimos la posicion con el mapa de valores al servo | |
delay(150); // Y le damos un tiempo para que sea capaz de moverse | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment