Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2. SoftwareSerial BlueTooth(5, 6); // (TXD, RXD) of HC-06
  3.  
  4. char BT_input; // to store input character received via BT.
  5.  
  6. void setup()
  7. {
  8. pinMode(13, OUTPUT); // Arduino Board LED Pin
  9. BlueTooth.begin(9600);
  10. }
  11.  
  12. void loop()
  13. {
  14. if (BlueTooth.available())
  15.  
  16. {
  17. BT_input=(BlueTooth.read());
  18. if (BT_input=='a')
  19. {
  20. digitalWrite(13, HIGH);
  21. BlueTooth.println("Now LED is ON");
  22. }
  23. else if (BT_input=='b')
  24. {
  25. digitalWrite(13, LOW);
  26. BlueTooth.println("Now LED is OFF");
  27. }
  28. else if (BT_input=='?')
  29. {
  30. BlueTooth.println("Send 'a' to turn LED ON");
  31. BlueTooth.println("Send 'b' to turn LED OFF");
  32. }
  33. if(BT_input == '!') {
  34. for(BT_input = 0 ; BT_input <= 20 ; BT_input ++){
  35. digitalWrite(13, HIGH);
  36. delay(75);
  37. digitalWrite(13, LOW);
  38. delay(70);
  39.  
  40. }
  41. }
  42.  
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement