Guest User

Untitled

a guest
Nov 18th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // Bluetooth Tutorial By Robo India
  2.  
  3. #include <SoftwareSerial.h>
  4. SoftwareSerial BlueTooth(5, 6); // (TXD, RXD) of HC-06
  5.  
  6. char BT_input; // to store input character received via BT.
  7.  
  8. void setup()
  9. {
  10. pinMode(13, OUTPUT); // Arduino Board LED Pin
  11. BlueTooth.begin(9600);
  12. }
  13.  
  14. void loop()
  15. {
  16. if (BlueTooth.available())
  17.  
  18. {
  19. BT_input=(BlueTooth.read());
  20. if (BT_input=='a')
  21. {
  22. digitalWrite(13, HIGH);
  23. BlueTooth.println("Now LED is ON");
  24. }
  25. else if (BT_input=='b')
  26. {
  27. digitalWrite(13, LOW);
  28. BlueTooth.println("Now LED is OFF");
  29. }
  30. else if (BT_input=='?')
  31. {
  32. BlueTooth.println("Send 'a' to turn LED ON");
  33. BlueTooth.println("Send 'b' to turn LED OFF");
  34. }
  35. // You may add other if else condition here.
  36. }
  37. }
Add Comment
Please, Sign In to add comment