74hc595.h:
#ifndef __74hc595_H__
#define __74hc595_H__
/************************************位定义************************************/
sbit DATA_IN = P1^0; //串行数据输入
sbit ST_CK = P1^1; //存储寄存器时钟输入
sbit SH_CK = P1^2; //移位寄存器时钟输入
/***********************************函数声明***********************************/
void Ser_IN(unsigned char Data); //串行数据输入
void Par_OUT(void); //串行数据输出
void Ser_IN(unsigned char Data)
{
unsigned char i;
for(i = 0; i < 8; i++)
{
SH_CK = 0; //CLOCK_MAX=100MHz
DATA_IN = Data & 0x80;
Data <<= 1;
SH_CK = 1;
}
}
void Par_OUT(void)
{
ST_CK = 0;
ST_CK = 1;
}
#endif
8x8LED.c
#include #include "74hc595.h" unsigned char i; unsigned int m,n; #define num sizeof(Digit_Tab) //代码长度 unsigned char code table[]={0xfe,0xfd,0xfb,0xf7,0xef,0xdf,0xbf,0x7f}; unsigned char code Digit_Tab[]= {//取模方式 阴码 列扫描 逆向 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x06,0x18,0x60,0x1D,0x60,0x18,0x06,0x00, 0x06,0x18,0x60,0x1C,0x60,0x18,0x06,0x00, 0x0B,0x1F,0x60,0x1C,0x60,0x18,0x06,0x00, 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00, 0x00,0x04,0x04,0x7E,0x4E,0x24,0x00,0x00, 0x00,0x44,0x28,0x10,0x28,0x44,0x00,0x00, 0x7C,0x02,0x02,0x7C,0x02,0x02,0x7C,0x00, 0x00,0x3C,0x42,0x42,0x42,0x24,0x00,0x00, 0x00,0x3E,0x40,0x40,0x40,0x3E,0x00,0x00, 0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00, 0x0A,0x3C,0x42,0x4C,0x42,0x24,0x00,0x00, 0x00,0x3C,0x42,0x42,0x42,0x3C,0x00,0x00, 0x7C,0x02,0x02,0x7C,0x02,0x02,0x7C,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x88,0x49,0x2A,0x1F,0xB9,0x49,0x8E,0x00, 0x0A,0xFF,0x1A,0x22,0x2B,0xFE,0x2B,0x22, 0x00,0x3E,0x2E,0x2A,0x7F,0xAA,0xAA,0xBF, 0x00,0x08,0x09,0x89,0x8D,0x7B,0x09,0x08, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, }; void Display(void) { Ser_IN((table[i])); //列扫描数据 Ser_IN(Digit_Tab[i + n]); //查表取出行扫描数据 Par_OUT(); //输出显示 i++; if(i == 8) { i = 0; } //循环扫描 m++; if(m == 300) { m = 0; n++; } //滚动速度控制 if(n == num - 7) { n = 0; //循环显示 } } void Timer0_init(void) { TMOD = 0xf8; TH0 = 0xcc; TL0 = 0x00; IE = 0x82; TR0 = 1; } void Timer0_intservice(void) interrupt 1 using 0 { TH0 = 0xf8; TL0 = 0xcc; Display(); } void main (void) { Timer0_init(); while(1); }
上一篇:单片机开发 --- 8X8LED点阵
下一篇:单片机实验——8X8LED点阵显示技术(二)
推荐阅读最新更新时间:2024-11-09 16:50
设计资源 培训 开发板 精华推荐
- LT4276BHUFD 25.5W(类型 2)PoE+ 电源在反激模式下的典型应用电路,具有 5V、4.7A 输出
- LTC3425,低成本、1.55mm 外形 3.3V 升压示例
- DC1498A,用于 LTM4620EV 高效率、双通道 13A 降压型电源稳压器的演示板
- EVAL-ADM2491EEBZ,用于工业网络的 3.3V、5V RS-485 收发器的评估板
- 观赏鱼缸控制器
- 用于 LCD 背光的 25W、23 个 LED 白光 LED 驱动器
- 使用 MaxLinear, Inc 的 SPX385M1-1.2 的参考设计
- 【航顺训练营】我要飞!
- STR-NCP110-EVK:支持 Strata 的 NCP110 - 200mA LDO,具有 0.6V 至 4V 的固定输出电压
- 12V/8A有源钳位正激转换器、符合IEEE 802.3bt标准的以太网供电(PoE)参考设计