Advertisement
fabiocftv

Arduino NANO HC05 - Slave

Sep 22nd, 2016
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //Programa : Modulo Arduino Bluetooth HC-05 - Recepcao
  2.  
  3.  
  4. //Armazena o caracter recebido
  5. char buf;
  6.  
  7. void setup()
  8. {
  9. //Define o pino 13 como saida
  10. pinMode(13, OUTPUT);
  11. Serial.begin(38400);
  12. }
  13.  
  14. void loop()
  15. {
  16. while(Serial.available() > 0)
  17. {
  18. buf = Serial.read();
  19. //Caso seja recebido o caracter L, acende o led
  20. if (buf == 'L')
  21. {
  22. digitalWrite(13, HIGH);
  23. }
  24. //Caso seja recebido o caracter D, apaga o led
  25. if (buf == 'D')
  26. {
  27. digitalWrite(13, LOW);
  28. }
  29. }
  30.  
  31. {
  32. //Envia pela serial o caracter F
  33. Serial.print("F");
  34. delay(3000);
  35. //Envia pela serial o caracter G
  36. Serial.print("G");
  37. delay(3000);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement