Advertisement
STANAANDREY

arduino tank led toggle with bluetooth

Aug 2nd, 2022 (edited)
1,043
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. void setup()
  2. {
  3.   Serial.begin(9600);
  4.   pinMode(LED_BUILTIN, OUTPUT);
  5. }
  6.  
  7. void loop()
  8. {
  9.   unsigned char ch = 0;                //Variable for storing Incoming_value
  10.   if(Serial.available())  
  11.   {
  12.     ch = Serial.read();      //Read the incoming data and store it into variable Incoming_value
  13.     if (ch == '1')
  14.       digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  15.     else
  16.       digitalWrite(LED_BUILTIN, LOW);   // turn the LED on (HIGH is the voltage level)
  17.  
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement