HDTV Antenna
& Tuner Box
GPS, Receivers
RF Modules
Voice Modules

Credit Card Payment

Follow us on Twitter Facebook

Getting started with LED

Level: beginning

We start our tutorials with LED which is one of the most commonly used in discuss electronics.LED We will how to put the components on the bread board based on the circuit diagram and introduce you to basic programming.

What is LED? A light-emitting diode (LED) is a diode, when switched on, electrons are recombined with holes within the device, releasing energy in photons. We find them on almost any device we use daily. They function as an indicator a device is on or simple as decoration like the Christmas lights.

The driving voltage of the LED is typically within the range of 2.2-3.4V. However, the output voltage of the input/output pins on the Basic Commander (BC) is about 5V with a supplied current of approximately 10mA. If such a voltage is directly applied on the LED, it may exceed the rated voltage of the LED. In order to protect the LED from being damaged due to over-voltage, it is necessary to add a resistor (R1) to limit the current.

A resistor is a small component which provides a resistant force to the current flowing in the electric wire. It is usually represented as "R" in Ω (Ohm). The resistance of a resistor can be identified with the four color rings. See fig. 1 on how to determine the resistance value.

Circuit Diagram

Let's put all the parts together. Before you start, make sure the Education board is power off. Connnect one pin of the resistor on pin5 (Port 4). The other pin on the bread board. The LED also has two pins or leads. Connect the long lead (positive) to the same line (line 5 on our bread board) as the resistor. Take a jumper wire from ground rail and connect to the short lead (negative) of LED (line 6) as shown in the picture below.

LED circuit diagram

That's it. The circuit is now complete. Before we can test the circuit we need a program to run the LED. This is because we have connected the componentes to the Port and not to VDD directly.

1Education Board with Basic Commander
1LED any color
1Resistor 330ohm
1Jump wire

All parts are included in the Explorer Kit.

Programming the LED

Let's take a look on how write a simple program to make the LED to flash. In our example, we will use the HIGH and LOW commands. First we turn the LED on with HIGH on pin 4. If you have connected the resistor to a different pin or port, make sure you change it on both lines in your code. Then we put PAUSE command to keep the LED on for 3 seconds before we turn it off with LOW command. This will give an flashing effect. You can modify the Pause time in milliseconds to a different duration.

      'Control by High, Low
      High 4 	'Set the Pin 4 to high level (5 volts) 
      Pause 3000 	'wait 3000 ms (3 sec)
      Low 4 	'Set the Pin 4 to low level (0 volt) 
      Pause 1000 	'wait 1000 ms (1 sec)

To keep the LED flashing for a few seconds, put the above code in a For-Loop:

      For x = 1 to 30 ' loop the on and off for 30 times
        'Set Control by High, Low
        High 4 	'Set the Pin 4 to high level (5 volts) 
        Pause 3000 	'wait 3000 ms (3 sec)
        Low 4 	'Set the Pin 4 to low level (0 volt) 
        Pause 1000 	'wait 1000 ms (1 sec)

Another helpful command is Toggle, which combines High and Low together. To simply your code, you make it short as follow:

      For x = 1 to 30 ' loop the on and off for 30 times
        'turn it on and off
        Toggle 4
        Pause 1000 	'wait 1000 ms (1 sec)

Copy the code into InnoBasic Workshop, compile and download the code to the BC. For information on other InnoBasic commands, see the InnoBasic manual.

Testing your program and circuit

Copy the code into InnoBasic Workshop. Compile your code to make sure there is no error. Connect the USB cable is connected to the Education Board and download it to the BC. Slide the power selection switch to position 2 and watch your LEDs flash.

What is next?

Now you are ready to move on to next step. Add another LED and make them blink alternatively. Add a third one, you can make a LED Traffic Light. If you have other ideas or projects with LED, email us your ideas or post your questions on our Forum.

Download: led.inb

  • Robot Kits
  • Commander Module
  • Commander Boards
  • Development Boards
  • Smart Modules
  • General Modules
  • Accessories
  • InnoBasic
  • catalogue

  • DIY Projects
  • ID MAP
  • Identifier List
  • InnoBasic Workshop

  • FAQ | Terms & Conditions | Contact Us

    Copyright © 2018 Kowatec Corporation. All rights reserved.