標題: STC89C51智能小車運行程序 [打印本頁]
作者: 餓餓額2 時間: 2018-6-7 16:47
標題: STC89C51智能小車運行程序
#include <reg52.h>
#define uchar unsigned char
#define uint unsigned int
sbit SET1=P2^4 ;
sbit SET2 =P2^5;
sbit SET3 =P2^6;
sbit SET4 =P2^7;
uchar code seg7code[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
void delay(uchar t) //延時程序1
{
uchar j;
while(t--)
{for(j=50;j>0;j--);}
}
void display ()
{
P2=P2|0XF0;
P0=~seg7code[1];
SET1=0;
delay(10);
P2=P2|0XF0;
P0=~seg7code[2];
SET2=0;
delay(10);
P2=P2|0XF0;
P0=~seg7code[3];
SET3=0;
delay(10);
P2=P2|0XF0;
P0=~seg7code[4];
SET4=0;
delay(10);
P2=P2|0XF0;
}
void main()
{
P1=0XFF;
P2=0XFF;
P3=0XFF;
P0=0XFF;
while(1)
{
display();
}
}
| 歡迎光臨 (http://m.raoushi.com/bbs/) |
Powered by Discuz! X3.1 |