www.eXtremeElectronics.co.in

On Board LEDs

AVR ATmega8 Bases Line Follower.

Easy to make PID LFR Robot.

The board has 5 onboard LEDs generally used to show the status of line sensors, that means when a black line comes just in the front of line sensor, corresponding LED is turned on. Each LED has a numeric id between 1-5.

LED id

PCB Marking

MCU I/O
1

D9 LEFT MOST

PD7
2

D8

PD6
3

D7

PD5
4

D6

PD4
5

D5 RIGHT MOST

PB0

 

LEDs can be controlled using the LED library that comes in as following files.

You can get these files from the lib folder in the DVD.

To use the LED Library do the following :-

  1. Create a new folder lib in the project using Solution Explorer.
  2. Create a new sub folder led inside the lib folder.
  3. Using Windows File Manager copy/paste the led.c and led.h files to your <project folder>/lib/led/ from the DVD.
  4. Add both files to your projects under lib/led.
  5. Now you are ready to use the library!

Using the LED library

The led library has following three functions.

void LEDInit(void)

This function initializes the i/o port drivers that are connected to LEDs. This function must 
be called before any of the functions below.

Arguments:
NONE

Returns:
NONE

    

 

void LEDOff(uint8_t id)

Turns off the LED referred by id. 
Arguments:
	id
	Type: uint8_t (unsigned 8 bit integer)
	Valid Range: 1-5

Returns:
NONE

    

void LEDOn(uint8_t id)

Turns on the LED referred by id. 
Arguments:
	id
	Type: uint8_t (unsigned 8 bit integer)
	Valid Range: 1-5

Returns:
NONE

    

Sample Program

The following sample program turns on each LED from id 1 to 5, then turns them off one by one from id 1 to 5.


/******************************************************************************

LFR Board Sample Programs

------------------------------------


Description :  The following sample program turns on each LED from id 1 to 5, 
            then turns them off one by one from id 1 to 5.

            This whole process is repeated again and again.


Author      : Avinash Gupta 2012
Web         : www.eXtremeElectronics.co.in

******************************************************************************/
#include <avr/io.h>
#include <util/delay.h>

#include "lib/led/led.h"

void Wait();

int main(void)
{
   LEDInit();

    while(1)
    {
        uint8_t i;

      for (i=1;i<=5;i++)
      {
         LEDOn(i);

         Wait();
      }

      for (i=5;i>0;i--)
      {
         LEDOff(i);

         Wait();
      }

    }
}

void Wait()
{
   uint8_t i;

   for(i=0;i<30;i++)
   {
      _delay_loop_2(0);
   }

}

HEX File Ready to Burn

The hex file ready to burn can be found in the Precompiled HEX Files folder in the Support DVD.

Return to Help Index.