Introduction: Using One LED As an Indicator for Different Events in Your System - Arduino

Picture of Using One LED As an Indicator for Different Events in Your System - Arduino

Many systems or machines undergo different events. For example, when you power up your laptop computer, an LED lights up to show power on state event. Another LED lights up when you plug in your charger; this other LED indicate a charging state event.

What to do:

1. Show power on state: when Arduino is powered up, provide a 100 microsecond blink every 1 second.

2. Show charging state: when a button is pushed, provide a 2 second blink every 3 seconds.

3. Show serial communication event: when the microcontroller receives a letter “S”, provide a 200 microsecond blink every 300 microseconds for 5 seconds.

What you need:

1) 1 LED (choose any color).

2) 1 220Ohms resistor.

3) 1 push button.

4) Arduino Uno (or equivalent).

5) Male to female jumper wires or breadboard.

How to make your circuit

From the above diagram, notice that ground terminals for LED and Button are connected to a common ground (GND) pin. The positive terminal of the LED (the longer terminal called anode) goes to the signal pin (pin 2) through 220 Ohms resistor. The 220 Ohms resistor provides a potential drop; this protects our LED from getting destroyed. The other terminal of the Button goes direct to signal pin (pin 3). There’s no technical reason as to why pin 2 and 3 were chosen. You can change them to your convenience.

How to program:

The program below shows the main program. You may include the functions part (the functions part is not included; download available):

#define LEDPIN 2
#define CHARGERPIN 3
#define ONESECOND 1000

const unsigned int baudRate = 9600;

void setup()
digitalWrite(CHARGERPIN, HIGH);

void loop()
boolean notCharging = digitalRead(CHARGERPIN);
switch (notCharging)
case false:
if (Serial.available())
char command =;
if (command == 'S')
for (int x=0; x < 10; x++)

You can get a full program from my original post HERE. You can download the full code and test. Remember to subscribe to my website for more. Leave me a comment there since I may not monitor comments here as much as i do HERE



DIY Hacks and How Tos (author)2016-02-06

Great way to make an event indicator.


About This Instructable




More by sirmaxford:Using one LED as an Indicator for different events in your system - Arduino
Add instructable to: