Show a number on a 7-segment LED display using an LED driver chipDr Nathan Scott & Dr Hiroyuki Kagawa · July 2002 In the previous tutorial you will have set up a single 7-segment LED display using the "direct drive" approach. In this section I will show you how to connect a 7-segment LED display to the AVR using a special purpose "LED driver" chip, which uses fewer of the available data pins on the AVR. |
LED表示専用ICを使った7セグLEDによる数字表示ネーサン・スコット(訳:香川博之) · 2002年7月 前章では7セグLEDを直接接続する方法について学習した。ここではAVRの数本の端子を利用するだけですむLED表示専用ICを使う方法について説明する。 |
|
|
|

Figure 1 Using the DM7447A to drive a 7-segment LED display such as the Agilent HDSP-5501
|
|
/*
Code for a crash course in AVR programming
Example "seven_seg_drv.c"
Dr Nathan Scott, July 2002
This program drives an external 7-segment common-anode LED display
using a BCD-to-7-segment driver IC such as the DM7447A
*/
#include "environment.h"
#include "delay.h"
void Idle()
// ignore this for now, it is used by the UART code in a later example
{
}
void main()
{
char i;
// set up control over PORTC
PORTC = 0; // put a definite start value into the register for PORTC
// - it's best not to leave this to chance
DDRC = 0x0F; // set the direction of some of the pins of PORTC to "output".
// note that we do not take control of the high 4 pins of PORTC, they
// can be used for some other function.
while (1) // endless loop, will run forever
{
for (i = 0; i < 0x0F; i++) // 16 possible combinations
{
PORTC = (PORTC & 0b11110000) | i ;
DelayMs(100); // human beings need time to read
}
}
}
|
Figure 2 Example program to count through the 16 possible symbols
|
|
Exercises
The CA3161 driver is good because
The disadvantages of the 7447 are
In later tutorials we will explore other ways to further extend the usefulness of the available IO pins, and thus make the AVR do more complex tasks. |
演 習
CA3161専用ICの長所
7447専用ICの短所
後章では,便利なI/Oの使い方を調査して,AVRにもっと複雑な作業をさせる。 |