Skip to main content

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.


Performing this basic task you should have a Arduino IDE on your PC or Laptop for write Arduino code to on/off LED.

These things you must have:
Arduino IDE.
Arduino Code which is given bellow.
Arduino Uno / smd r3.
10K resistor.
LED.




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

int ledpin = 13;

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

}
}
}
}


and verity and upload it to Arduino IDE and perform basic task. if you wanna learn each and every step then watch till end this videos.



Comments