Created
January 21, 2018 01:30
-
-
Save esmarr58/b58d221d2baaa2815b4643e076035c4c 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
/* | |
Programa Modulo Bluetooth-SLAVE | |
El siguiente programa recibe la informacion desde un modulo Bluetooth(HOST). | |
El envio de un '1', PRENDE el LED conectado al pin 12. | |
El envio de un '0', APAGA el LED conectado al pin 12. | |
*/ | |
#include <Servo.h> | |
Servo myservo; // Crea un objeto servo para controlar el servomotor | |
char state = 0; | |
void setup() | |
{ //inicializa la comunicacion serial | |
Serial.begin(9600); | |
myservo.attach(4); // asocia el servo en pin 3 al objeto servo} | |
//se configura los pines de entrada y salida | |
delay(150); | |
} | |
void loop() | |
{ if(Serial.available() > 0){ | |
state = Serial.read(); | |
Serial.println(state); | |
} | |
myservo.write(state); // fija la posición del servo de acuerdo al valor escalado | |
delay(15); // espera a que el servo se posicione | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment