How To Turn On Off LED Using Serial Monitor Arduino

How To Turn On/Off LED Using Serial Monitor Arduino

Posted on

How To Turn On/Off LED Using Serial Monitor Arduino – Arduino is currently among the best in learning microcontrollers. More than thousands of projects have been made by Arduino. Various conveniences in using it include communicating using serial monitors.

How To Turn On Off LED Using Serial Monitor Arduino

This article is the basis of using serial commands in Arduino programming. This time we will learn to use Serial Monitor to send one caracters to Arduino to turn on or off an LED.  We don’t need External LED right now, but we use internal LEDs on Arduino. This LED is connected to pin 13.

This Turn On/Off LED Using Serial Monitor Arduino article only for beginner. Please upload following program to your Arduino.

int led = 13;
char  i;


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

void loop() {
  if (Serial.available() > 0) {
    i = Serial.read();
    Serial.println(i);

    if (i == '1') {
      digitalWrite(led, HIGH);
      delay(10);
    }

    else if (i == '0'){
      digitalWrite(led, LOW);
      delay(10);
    }
  }
}

Open your serial Monitor in Arduino IDE. Type caracter “1” for turn On and Enter. Them type character of “0” for turn Off the LED. Look at this video:

Read other articles  How Turn On/Off an LED using Arduino

Leave a Reply

Your email address will not be published. Required fields are marked *