周末回家,正漫无目的的浏览着网站,突有一QQ消息弹出自称是大学学生因不熟悉单片机,老师催作业太急,需要求助,题目大概如下
正好闲着没事,就说我们也是那个时候过来的,就来随便写写,看下当初的东西是否都还给老师了,就打开了MDK开始敲起来,大概半小时终于完成了,小伙伴们来围观下,嘿嘿。虽然它的电路图漏洞百出,不过看起来应该是个示意图,所以我的程序也算是示意,逻辑大概通顺,没有编译调试过,也可能有语法错误不过这不影响我回忆单片机的心情。O(∩_∩)O
#include
static unsigned code char DecodeNum[16]={0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f};//需要调试,取字模,解码
#typedef ONE 1//select the first LED
#typedef TWO 2//select the second LED
#typedef THR 3//select the third LED
#typedef FOR 4//select the four LED
#typedef Delay1MS1
#typedef Delay100MS 100
#typedef Delay1S 100000
//output 8 bit date to port 0
void Out8(uniigned char Data8)
{
P0 = Data8;
}
//select one LED to show the data output from port0
void Cs(Unsigned char Data8)
{
switch(Data8)
{
case ONE:
{
P2^1=0;
break;
}
case TWO :
{
P2^2=0;
break;
}
case THR :
{
P2^3=0;
break;
}
case FOR :
{
P2^4=0;
break;
}
default break;
}
}
//show one data on the selected LED
void Put8(unsigned char Data8,unsigned char Cs)
{
Out8(DecodeNum[Data8]);
Cs(Cs);
}
//show a string on the for LED
void Puts8(unsigned char *Data8,Unsigned char Length)
{
unsigned int i;
for(i=0;i{
i=i%FOR;
Put8([*Data8++],i+1);
Delay(Delay100MS);
}
}
//Delay for a while
void Delay(unsigned int Time)
{
ungingned int i;
for(i=0;i
先到这里。
转载请注明出处
Cstyle.z.zhou@gmail.com // http://blog.csdn.net/CStyle_0x007