救救孩子吧,一道单片机题目:使用74LS165完成并行数据到串行数据的转换,拨码开关控制数码管的显示。例如按下D0,显示0;D1显示1以此类推。啊啊啊要怎么写呀!!!!!!附上我写的代码(菜鸟乱写的)
求解答…
。 ∧_∧。゚
゚ (゚ ´Д`゚)っ゚
(つ /
| (⌒)
し⌒
#include <reg52.h>
#include <intrins.h>
#include <stdio.h>
#define uint unsigned int
#define uchar unsigned char
sbit SPL = P2^5;
uchar code DSY_CODE[]=
{
0x00,0x3f,0x06,0x5b,0x4f,0x66,0x6d, 0x7d,0x07,0x7f,0x6f
};
void Delay(uint x)
{
uchar i;
while(x--)
{
for(i=0;i<120;i++);
}
}
void main()
{
uchar temp;
SCON = 0x10;
while(1)
{
SPL = 0;
SPL = 1;
while(RI == 0);
RI = 0;
temp=~SBUF;
P0 = DSY_CODE[temp];
Delay(200);
}
}