TABLE 1. Bill of Materials (BOM)
for the LED Display Board.
Item
Qty
Source
Description
1
1
RadioShack
Prototype PC board
2
1
RadioShack
10 LED BAR display
3
1
Jameco
4
8
Jameco
270 ohm 16 pin DIP
resistor, isolated
Straight .001 pin
headers
5
1
IFI
VEX controller
• Signs of smoke or sparks: Disconnect the controller
and circuits from the power source.
The simplest circuit that you can build is to just insert
// Setup timers, configure ports and
initialize variables
Setup Timers();
// Initialize the LED Display
InitializeLED();
// Test LEDs
while(1)
{
for (i=0; i<256; i++)
{
// Set the LEDs connected to
// PORTA pins
PORTA = i;
pause(5000);
}
LISTING 1.
}
52 SERVO 03.2010
one or more LEDs into any of the 16 digital outputs,
making sure that the cathode (end with a notch) of each
LED is connected to ground (-) and the anode (+) is
connected to the middle port. A simple C application sets
the selected output pin to 1 to turn the LED on 0 to turn
the LED off. There is no need to use a current-limiting
resistor since the VEX microcontroller provides a 1K ohm
resistor in series with the output port.
In this experiment, the VEX microcontroller is used to
blink from one to eight LEDs that are contained in a display.
This will demonstrate the microcontroller’s digital output
capabilities. The completed circuit for the LED driver
assembled on a breadboard and wired to the
microcontroller’s digital output pins is shown in Figure 4.
Each LED is connected to one of the digital output pins and
is toggled so that they turn on or off using a simple Easy C
or PIC18 C program (as shown in Listing 1). In order to
access the digital output pins, insert eight .100 3 x 1 pin
headers into the digital/analog block on top of the
microcontroller. The outputs of these pins can be connected
to corresponding pin headers on a prototype board; use
wire wrapper or jumper cables to make the connections as
shown in the schematic in Figure 5. (It shows how the
eight LEDs can be connected to the digital output pins.)
The simple, experimental platform shown in Figure 4
consists of the VEX microcontroller, LED display, numeric
LED display, LCD display, five motors, a Parallax motor
controller, and a VEX 9. 6 volt battery. This setup provides
the test-bed to carry out this and future experiments.
There are basically two ways to connect LEDs to
microcontrollers. The first way is to source the current to
the LED. This means that sending a logic 1 to an output
port, representing a voltage of + 5 volts (TTL) will light the
LED. The second way is to sink the current to the LED by
sending a 0 to the output port, representing a voltage of
0V. The schematic here only shows the source connection.
The 9. 6 volt/1,000 mAh rechargeable battery is a portable
power source and is regulated internally by the
microcontroller to + 5 volts. This is enough to power our
eight LEDs.
Making the LED Display
The components that I used to build the LED display
circuit are shown in Table 1. Other than the VEX
microcontroller, the required resistors and LEDs are low-cost
components you can find at places like Jameco.
Port A bits 0: 5 are mapped to the microcontroller’s
digital/analog pins 1 through 16 as shown in Table 2. The
16 I/O pins are mapped to the PIC18F8520 port bits also
shown in the table). The ones used for the LEDs are noted.
Other experiments will use this mapping as well.
The LED application written in Easy C counts from 0 to
255 using the eight LEDs with a . 5 second pause delay
between each count.
Notice how Easy C provides the necessary I/O functions
to toggle the LEDs. The LEDs can also be used as a low-cost
LED digital scope, logic analyzer, or logic probe.