Created
June 24, 2015 16:54
-
-
Save chepecarlos/fe6faa5be9685d5b9a99 to your computer and use it in GitHub Desktop.
Demo de encender un led con HC-05
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 <SoftwareSerial.h>//Se puede emular mas de un puerto serial | |
int Led = 13;// I/O donde esta conectado el led | |
SoftwareSerial BTSerial(3, 2); // RX | TX Poner los pines que usas | |
void setup() { | |
pinMode(Led, OUTPUT); | |
BTSerial.begin(9600);//Inicializar comunicacion | |
} | |
void loop() { | |
while (BTSerial.available()) { | |
char data = (char)BTSerial.read(); | |
if ( data == 'H') | |
digitalWrite(Led, 1); | |
else if ( data == 'L') | |
digitalWrite(Led, 0); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment