Watch the Video Tutorial

A Light Emitting Diode (LED) is a semiconductor light source, when forward biased, it emits light. 
LEDs are used mainly to indicate the status of electronic circuits, for example to indicate that power is on or off but nowadays they are used in many applications including lighting and beam detection. 
Early LEDs emitted low-intensity red light, but today high brightness and many colour LEDs are available (white, blue, red, green, yellow or even infrared). 
LEDs have many advantages over the traditional lights (the incandescent and neon light bulbs)  such as: low voltage of operation, very low  energy consumption, smaller size, longer lifetime, available in many colours etc. In many energy efficient applications, the LEDs are tending to replace the traditional light source.

All of us start learn a new programming from Hello World. In microcontroller fields the Hello World example is usually blinking an led, in this article we will learn how to Blink an LED with Arduino. 

Connecting LEDs

An LED is similar to a diode, it has two legs: the longer leg is the anode (+) and the shorter leg the cathode (-). The cathode is also identified by a flat side on the body. 
The intensity of the light emitted by an LED depends on the amount of forward current passed through the device but we must take attention not to exceed the maximum allowable forward current or draw more current than the Arduino output pin can handle. or this reason it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1k resistors, unless maximum current draw from the pins is required for a particular application.

Figure 1 below shows an LED on Breadboard connected to pin D7 of the Arduino. This is the beauty of Arduino, it make prototyping very easy. With a Breadboard and an arduino board, you can do wonders. The Anode pin of the LED is connected to D7 with a 470Ω current limiting resistor.

Figure 1: LED connected to pin D7

Writing the Flowchart

Now let us make a simple Flowchart to blink an external LED connected to a digital pin (say 7) of Arduino. The ON time will be 2 seconds and the OFF time 1 second.

Start a new project, under the choose a Target, select Arduino (ARD), if you are using Flowcode v6 select AVR/Arduino, then in the family section, select Arduino Uno R3 PDIP. But you can use a different Arduino board as well, in this example we will use the Arduino Uno.

Add an LED to 3D system panel or to 2D dashboard and connect it to Arduino Digital pin 7 (PORTD.7)

To learn more how to add components on System panel and components settings, please read: Connecting Light Emitting Diode to a PIC Microcontroller Flowcode article.

The Arduino Uno R3 uses the ATMEGA328P chip, to know which ATMEGA328P pin corresponds to Arduino D7, open the chip window under the VIEW menu, click on Chip. From the figure below, Arduino Digital pin 7 correspond to ATMEGA328P PD7 pin.

Add two Components Macro, two delay icons inside a loop as shown on figure below.

Component macros are pre-defined macros supplied with the components. For example LED macros are used to Turn ON or Turn OFF an LED. Component macros are only available for use with that particular component.
Component macros have hatched outer bands on the icon.

The first Component macro, select TurnOn() to Turn ON the LED and the second select TurnOff() to turn it OFF.

In this example we’re gonna switch ON the LED for 2 seconds and OFF for 1 second, so th efirst delay icon enter 2 seconds and the second 1 second for the OFF time.

Run the program, it should blink ON foe 2S and OFF for 1S.

Compile to chip to generate an Hex file and load it into the Arduino. You can also simulate with Proteus by loading the hex file generated by Flowcode.

Simulate Arduino with Proteus ISIS

Proteus is the most powerful tool in simulating microcontroller circuits. Follow these few steps to simulate your Arduino circuit with Proteus:

  • Right-click the Arduino board in PROTEUS and select the .HEX file generated by Flowcode.

  • Now you can run your simulation as shown below.

You can download the full project files (Arduino and Proteus project) below here. All the files are zipped, you will need to unzip them (Download a free version of the Winzip utility to unzip files).  

Download: Blink_LED_Arduino_Flowcode

Download: Arduino_Flowcode_Blink_Proteus