AJ-Explains-It-All
Published © GPL3+

LED Control via Serial Communication

I will further extended my last project on serial communication by writing a program that controls the built-in LED on the Arduino Uno.

BeginnerFull instructions provided30 minutes2,096
LED Control via Serial Communication

Things used in this project

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

CODE

Arduino
void setup()

{

pinMode(13, OUTPUT);

Serial.begin(9600);

while (!Serial);

Serial.println("Input 1 to Turn LED on and 2 to off");

}

void loop() {

if (Serial.available())

{

int state = Serial.parseInt();

if (state == 1)

{

digitalWrite(13, HIGH);

Serial.println("Command completed LED turned ON");

}

if (state == 2)

{

digitalWrite(13, LOW);

Serial.println("Command completed LED turned OFF");

}

}

}

Credits

AJ-Explains-It-All

AJ-Explains-It-All

12 projects • 10 followers
Experienced embedded firmware and software developer. I have a great affinity towards ARM cortex based MCU's.

Comments