Lets On/OFF LED using Arduino Programming and Circuit | Basic To Advanced Languages | Arduino Lesson Part 2
Lets ON/OFF LED Using Arduino Circuit and Programming.
In this Videos we'll discuss Controlling Led On/Off Arduino Programming in detail, then we will plug/insert Led into the Arduino Circuit in last we will perform Outputs.
The code for you to test.
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // set baud rate speed of communication
pinMode(13, OUTPUT ); // led of output function
}
void loop() {
  // put your main code here, to run repeatedly:
{
if(Serial.available()) // if there is digital pin as output
{
  String command = Serial.readStringUntil ('\n');   // read String Until Meet newline character
     
       if( command == "ON")  
{
digitalWrite(13, HIGH); // turn on LED
        Serial.println("LED is Turn ON");  // send action to Serial Monitor  
}
       else if ( command =="OFF")
     
    {
        digitalWrite(13, LOW );        // TURN OFF LED
        Serial.println("LED is Turned OFF");   // send action to Serial Monitor 
        
      }
}
}
}
OR
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // set baud rate speed of communication
pinMode(ledpin, OUTPUT ); // led of output function
}
void loop() {
  // put your main code here, to run repeatedly:
{
if(Serial.available()) // if there is digital pin as output
{
  String command = Serial.readStringUntil ('\n');   // read String Until Meet newline character
     
       if( command == "ON")  
{
digitalWrite(ledpin, HIGH); // turn on LED
        Serial.println("LED is Turn ON");  // send action to Serial Monitor  
}
       else if ( command =="OFF")
     
    {
        digitalWrite(ledpin, LOW );        // TURN OFF LED
        Serial.println("LED is Turned OFF");   // send action to Serial Monitor 
        
      }
}
}
}
Comments
Post a Comment