Advertisement
fabiocftv

Nano - Recepção

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