Advanced PIC Microcontroller Projects in C: From USB to RTOS with the PIC18F Series

Project 6.1: Chasing LEDs

Project 6.1: Chasing LEDs

Project Description

In this project eight LEDs are connected to PORTC of a PIC18F452-type microcontroller, and the microcontroller is operated from a 4MHz resonator. When power is applied to the microcontroller (or when the microcontroller is reset), the LEDs turn ON alternately in an anticlockwise manner where only one LED is ON at any time. There is a one-second delay between outputs so the LEDs can be seen turning ON and OFF.

An LED can be connected to a microcontroller output port in two different modes: current sinking and current sourcing.

Current Sinking Mode

As shown in Figure 6.1, in current sinking mode the anode leg of the LED is connected to the +5V supply, and the cathode leg is connected to the microcontroller output port through a current limiting resistor.


Figure 6.1: LED connected in current sinking mode

The voltage drop across an LED varies between 1.4V and 2.5V, with a typical value of 2V. The brightness of the LED depends on the current through the LED, and this current can vary between 8 and 16mA, with a typical value of 10mA.

The LED is turned ON when the output of the microcontroller is at logic 0 so the current flows through the LED. Assuming the microcontroller output voltage is about 0.4V when the output is low, we can calculate the value of the required resistor as follows:

where

  • V S is the supply voltage (5V)

  • V LED is the voltage drop across...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Light Emitting Diodes (LED)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.