Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled LED with Serial Communication

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled LED with Serial Communication

Circuit Documentation

Summary

This circuit consists of an Arduino UNO microcontroller, a red LED, and a 220 Ohm resistor. The Arduino UNO controls the LED based on serial input commands. When the command "on" is received, the LED lights up; otherwise, it remains off.

Component List

Arduino UNO

LED: Two Pin (red)

Resistor

Wiring Details

Arduino UNO

LED: Two Pin (red)

Resistor

Code Documentation

Arduino UNO Code

void setup(){
  pinMode(9, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  if (Serial.available()>0){
    String data = Serial.readStringUntil('\n'); 
    Serial.println(data);
    if (data=="on"){
        digitalWrite(9,HIGH);
    } 
    else{
      digitalWrite(9,LOW);
    }
  }
}

Explanation: