8*8点阵proteus仿真与数码管原理图如下:
单片机源程序:
- #include <reg52.h>
- //此表为 LED 的字模, 共阴数码管 0-9 -
- unsigned char code Disp_Tab[] = {0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40}; //段码控制
- //此表为8个数码管位选控制, 共阴数码管 1-8个 -
- unsigned char code dispbit[8]={0xfe,0xfd,0xfb,0xf7,0xef,0xdF,0xbF,0x7F}; //位选控制 查表的方法控制
- unsigned char led_buffer0[8]={0x01,0x03,0x07,0x0f,0x1f,0x3f,0x7f,0xff};
- unsigned char code led_buffer[]={
- /*-- 调入了一幅图像:C:\Users\Administrator\Pictures\numb.bmp --*/
- /*-- 宽度x高度=80x8 --*/
- 0x00,0x00,0x3E,0x51,0x49,0x45,0x3E,0x00,
- 0x00,0x00,0x00,0x42,0x7F,0x40,0x00,0x00,
- 0x00,0x00,0x62,0x51,0x49,0x45,0x42,0x00,
- 0x00,0x00,0x22,0x49,0x49,0x49,0x36,0x00,
- 0x00,0x00,0x18,0x14,0x12,0x7F,0x10,0x00,
- 0x00,0x00,0x2F,0x49,0x49,0x49,0x31,0x00,
- 0x00,0x00,0x3E,0x49,0x49,0x49,0x32,0x00,
- 0x00,0x00,0x01,0x01,0x79,0x05,0x03,0x00,
- 0x00,0x00,0x36,0x49,0x49,0x49,0x36,0x00,
- 0x00,0x00,0x26,0x49,0x49,0x49,0x3E,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
- };
- unsigned char disp_count=0,numb=0;
- unsigned char hour=23,min=45,sec=58;
- unsigned int count=0;
- bit flash=0;
- void delay(long dly)
- {
- while(dly--);
- }
- void main()
- {
- unsigned char i;
- TMOD=0X01;
- TH0=(65536-1000)/256;
- TL0=(65536-1000)%256;
- TR0=1;
- ET0=1;
- EA=1;
- while(1)
- {
- // get_clock();
- delay(3000);
- numb++;
- if(numb>79)
- {
- numb=0;
- }
- }
- }
- void TIMER0_ISR(void) interrupt 1
- {
- P2=0x00;
- TH0=(65536-1000)/256;
- TL0=(65536-1000)%256;
- P0=~led_buffer[numb+disp_count];
- P3=~led_buffer[numb+8+disp_count];
- P2=~dispbit[disp_count];
- disp_count++;
- if(disp_count>7)
- {
- disp_count=0;
- }
- count++;
- if(count>249)
- {
- count=0;
- flash=!flash;
- }
- }
复制代码
下载:
8X8点阵.rar
(54.61 KB, 下载次数: 45)
|