next up previous
Next: What you should have Up: Analog and Digital Interfacing Previous: Resistive and Capacitive Loads

Learning Module Exercise

In this learning module, you'll build a system that increments or decrements the integer value displayed on a single seven-segment LED display. A seven-segment LED display is an integrated circuit containing seven LED's that are arranged to display numbers. The typical arrangement of the LED's is shown in figure 20. By turning on the appropriate segments, we can display the numbers $0$ to $9$.

Figure 20: Seven segment display
\begin{figure}\centerline{\psfig{file=figs/seven-segment.eps,width=4in}} \end{figure}

Figure 20 shows the pin assignments for the seven segment LED (LSD3221-11). You'll connect these LED's in series with a ULN2003A Darlington transistor array. The ULN2003A consists of 7 Darlington transistor arrays that act precisely like the buffer shown in the right hand circuit in figure 19. Because we're using a Darlington array (rather than the MicroStamp11) to drive the LED's, we can use smaller resistors ($500 \Omega$) as current limiters, thereby increasing the brightness of the LEDs.

Figure 20 shows the connections between the MicroStamp11 and the seven segment LED display. This module, however, also asks you to connect to button to the MicroStamp11. One button will be used to increment the number displayed on the LED and the other button will be used to decrement the number displayed on the LED. A schematic illustrating the recommended connection for these buttons is shown in figure 21. One button is connected to input pin PA0 and the other button is connected to input pin PA1.

Figure 21: Learning module's input buttons
\begin{figure}\centerline{\psfig{file=figs/button-module.eps,width=3in}} \end{figure}

Now that the hardware side of this module has been completed, we turn to the software side. A listing of the program will be found below.

  #include"kernel.c"

  void main(void){
    int ilevel;
    int istep;

    init();
    ilevel=0;
    display_digit(ilevel);

    while(1){
      istep=butcontrol();
      ilevel=(ilevel+istep)%8;
      display_digit(ilevel);
  }
  #include"vector.c"
This program displays the integer variable ilevel on the LED display using the function display_digit(). The function butcontrol() determines which button (the increment or decrement) was pushed and then returns either $+1$ or $-1$ in the integer variable istep. The variable ilevel is then incremented with istep modulo 8, so that the displayed digit always lies between 0 and 8.

The function display_digit() has the prototype

  void display_digit(int data);
This function assumes that the pin assignments used in figure 20 are being used. The other function butcontrol() has the prototype
  int butcontrol(void);
This function assumes that the buttons are connected as shown in figure 21. Both functions have been included in the kernel.c listing. A detailed listing of this kernel is provided as an appendix at the end of this learning module.


next up previous
Next: What you should have Up: Analog and Digital Interfacing Previous: Resistive and Capacitive Loads
Bill Goodwine 2002-09-29