工具:
1、R8C1B学习板
2、74HC595驱动LED
3、HEW软件以及NC30
已经达到目标:
1、实现LED显示,74HC595级联驱动N个LED显示
2、使用3个IO口
3、脱机可以运行,串口下载后去掉MODE跳线,RESET即可脱机运行
备注:
LED模块原理图
显示效果图:
74HC595驱动:
#include "sfr_r81B.h"
#include "led.h"
const unsigned char LED_SEG_TAB[]={0xfc,0x60,0xda,0xf2,0x66,0xb6,0xbe,0xe0,0xfe,0xf6,0xee,0x3e,0x1a,0x7a,0x9e,0x8e,0x01};
//01234567890abcdef.
void Led_Send_Byte(unsigned char data)
{
unsigned char i,temp;
temp=data;
for(i=0;i<8;i++)
{
if((temp & 0x01)==0)
{SER=0;}
else
{SER=1;}
SCK=0;
SoftWait(100);
SCK=1;
temp=temp/2;
}
}
void Led_Lock(void)
{
RCK=0;
SoftWait(100);
RCK=1;
}
void Led_Send_Buf(unsigned char *buf,unsigned char count)
{
unsigned char i;
for(i=0;i<count;i++)
{
Led_Send_Byte(LED_SEG_TAB[*buf]);
buf++;
}
Led_Lock();
}
文章评论(0条评论)
登录后参与讨论