Advertisement
RuiViana

Serial e Bluetooth

Jan 10th, 2016
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. SoftwareSerial bt(53 , 52); // TX RX
  4. byte caractere;
  5. byte portao = 49; // 1 a
  6.  
  7.  
  8. void setup()
  9. {
  10. Serial.begin(9600);
  11. bt.begin(9600);
  12. pinMode(portao, OUTPUT);
  13. }
  14.  
  15. void loop()
  16. {
  17. if (bt.available())
  18. {
  19. caractere = bt.read();
  20. if (caractere == 'A')
  21. {
  22. digitalWrite(portao, HIGH); // 1 a
  23. bt.println("OK, port A/F.");
  24. }
  25. if (caractere == 'a')
  26. {
  27. digitalWrite(portao, LOW);
  28. bt.println("OK, port a/f.");
  29. }
  30. }
  31. char ler = 0;
  32. if(Serial.available())
  33. {
  34. ler = Serial.read();
  35. Serial.println(ler);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement