Advertisement
Tanzil1312n

Bluetooth light

Jul 10th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. void setup() {
  2. Serial.begin(9600);
  3. pinMode(8, OUTPUT); // put your setup code here, to run once:
  4. }
  5.  
  6. void loop() {
  7. // put your main code here, to run repeatedly:
  8. if(Serial.available()>0)
  9. {
  10. char data= Serial.read(); // reading the data received from the bluetooth module
  11. switch(data)
  12. {
  13. case 'a': digitalWrite(8, HIGH);break; // when a is pressed on the app on your smart phone
  14. case 'd': digitalWrite(8, LOW);break; // when d is pressed on the app on your smart phone
  15. default : break;
  16. }
  17. Serial.println(data);
  18. }
  19. delay(50);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement