Advertisement
Tanzil1312n

Bluetooth controller light

May 8th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. /*
  2. * Bluetooh Basic
  3. * Website - https://earthbondhon.com/arduino-bluetooth-controller-lamp-with-relay-module/
  4. * Download the App : https://drive.google.com/open?id=1qvWglHJsDgepvZR3xCUbs210-ozNjHz7
  5. * This program lets you to control a LED on pin 13 of arduino using a bluetooth module
  6. */
  7. char Incoming_value = 0; //Variable for storing Incoming_value
  8. void setup()
  9. {
  10. Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data transmission
  11. pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
  12. }
  13. void loop()
  14. {
  15. if(Serial.available() > 0)
  16. {
  17. Incoming_value = Serial.read(); //Read the incoming data and store it into variable Incoming_value
  18. Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor
  19. Serial.print("\n"); //New line
  20. if(Incoming_value == '1') //Checks whether value of Incoming_value is equal to 1
  21. digitalWrite(13, HIGH); //If value is 1 then LED turns ON
  22. else if(Incoming_value == '0') //Checks whether value of Incoming_value is equal to 0
  23. digitalWrite(13, LOW); //If value is 0 then LED turns OFF
  24. }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement