safwan092

Untitled

Feb 20th, 2020
103
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<SoftwareSerial.h>
  2. int Rx = 2;
  3. int Tx = 3;
  4. SoftwareSerial bluetoothSerial(Tx, Rx); // define the bluetooth
  5. char c; // variable c to store data
  6. int led = 13;
  7. void setup() {
  8. bluetoothSerial.begin(9600); // speed of bluetooth
  9. Serial.begin(9600);
  10. pinMode(led, OUTPUT);
  11. digitalWrite(led, HIGH);
  12. Serial.println("LED ON");
  13. }
  14.  
  15. void loop() {
  16. if (bluetoothSerial.available()) {
  17. c = bluetoothSerial.read();
  18. Serial.println("Bluetooth data avaliable");
  19. Serial.println(c);
  20. if (c == '1') {
  21. digitalWrite(led, HIGH);
  22. Serial.println("LED ON");
  23. }
  24. if (c == '0') {
  25. digitalWrite(led, LOW);
  26. Serial.println("LED OFF !!!!!!!");
  27. }
  28. }
  29. Serial.print(".");
  30. }
RAW Paste Data