Advertisement
Jorge_moises

bluetooth liga e desliga led

Aug 31st, 2014
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #include <SoftwareSerial.h>//chama biblioteca Bluetooth
  2. SoftwareSerial Bluetooth (10, 11); //RX, TX
  3.  
  4. byte led_1 = 2;
  5. byte led_2 = 3;
  6. int Blue_data;
  7.  
  8. void setup(){
  9. //Serial.begin(9600);
  10. Bluetooth.begin (9600);//velocidade serial para o bluetooth
  11. pinMode (led_1, OUTPUT);
  12. pinMode (led_2, OUTPUT);
  13. //funLed();
  14. }
  15. void loop(){
  16. if (Bluetooth.available());
  17. {
  18. Blue_data = Bluetooth.read();
  19.  
  20. //---------------- LED 1
  21.  
  22. if (Blue_data == '1'){
  23. digitalWrite (led_1, HIGH);
  24. //Bluetooth.println ("Rele 1- ON");//print no celular
  25. }
  26. if (Blue_data == '2'){
  27. digitalWrite (led_1, LOW);
  28. // Bluetooth.println ("Rele 1- OFF");//print no celular
  29. }
  30.  
  31. // -------------- LED 2
  32. if (Blue_data == '3'){
  33. digitalWrite (led_2, HIGH);
  34. // Bluetooth.println ("Rele 2 - ON");//print no celular
  35. }
  36. if (Blue_data == '4'){
  37. digitalWrite (led_2 , LOW);
  38. //Bluetooth.println ("Rele 2 - ON");//print no celular
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement