Advertisement
Jorge_moises

Bluetooth HC-05

Aug 30th, 2014
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 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. }
  14. void loop(){
  15. if (Bluetooth.available())
  16. {
  17. Blue_data = Bluetooth.read();
  18.  
  19. //---------------- LED 1
  20.  
  21. if (Blue_data == '1'){
  22. digitalWrite (led_1, HIGH);
  23. //Bluetooth.println ("Rele 1- ON");//print no celular
  24. }
  25. if (Blue_data == '2'){
  26. digitalWrite (led_1, LOW);
  27. // Bluetooth.println ("Rele 1- OFF");//print no celular
  28. }
  29. // -------------- LED 2
  30.  
  31. if (Blue_data == '3'){
  32. digitalWrite (led_2, HIGH);
  33. // Bluetooth.println ("Rele 2 - ON");//print no celular
  34. }
  35. if (Blue_data == '4'){
  36. digitalWrite (led_2 , LOW);
  37. //Bluetooth.println ("Rele 2 - ON");//print no celular
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement