Skip to content

Instantly share code, notes, and snippets.

@esmarr58
Created January 21, 2018 01:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save esmarr58/b58d221d2baaa2815b4643e076035c4c to your computer and use it in GitHub Desktop.
Save esmarr58/b58d221d2baaa2815b4643e076035c4c to your computer and use it in GitHub Desktop.
/*
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