这个程序依次显示0-7,其中,一个管脚点亮显示,一个管脚送显示的字模。
显示管用的是proteus的SEG_MPX8_CA_BLUE CA共阳common Anode CC共阴common catnode
程序如下:
- #define F_CPU 8000000UL
- #include <avr/io.h>
- #include <util/delay.h>
- #include <stdint.h>
- const uint8_t SEG_CODE[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
- int main(void)
- {
- uint8_t i;
- DDRC = 0xFF;
- DDRD = 0xFF;
- while(1)
- {
- for(i=0;i<8;i++)
- {
- PORTD=_BV(i);
- PORTC= SEG_CODE[i];
- _delay_ms(40);
- }
- }
- }
Proteus 仿真如下:
Studio 6.2 编译截图:
|