http://boke.qq.com/play.html?v=7MlxuKAsPrY
简单的开机了.................
问题多多
控制程序
// 录象由于要1~2天才能通过审核.... 代码已经是从新写过的了
#include <reg51.h>
#include <intrins.h> //内部包含延时函数 _nop_();
#define uchar unsigned char
#define uint unsigned int
sbit key1 = P3^2; //进入设置菜单
sbit key2 = P3^3; //确定设置
sbit key3 = P3^4;
sbit key4 = P3^5;
sbit key5 = P3^6; // a1 ++
sbit key6 = P3^7; // a ++
sbit key8 = P3^0; // a1 ++
sbit key9 = P3^1;
uchar code table[]={0x28,0xeb,0x32,0xa2,0xe1,0xa4,0x24,0xea,0x20,0xa0,0xff};
uchar code zj1[8]={0x01,0x03,0x02,0x06,0x04,0x0c,0x08,0x09}; //P10~3. P20-3
uchar code fj1[8]={0x09,0x08,0x0c,0x04,0x06,0x02,0x03,0x01}; //P10~3. P20-3
uchar code zj2[8]={0x10,0x30,0x20,0x60,0x40,0xc0,0x80,0x90}; ////P14~7.
uchar code fj2[8]={0x90,0x80,0xc0,0x40,0x60,0x20,0x30,0x10}; ////P14~7.
void delay(uint z);
uint aaa,bbb,ccc,ccc2,ggg,ggg2 ;
uchar smg,i2,i;
void time0_int(void) interrupt 1
{
TR0=0;
TH0=(65536-1000)/256;
TL0=(65536-1000)%256;
smg++; //数码管
//ccc++; //
ggg++; // 电机1
ggg2++; // 电机2
TR0=1;
}
/********************************************************/
void delay(uint z)
{
do{
_nop_();_nop_();_nop_();
}while(--z);
}
main()
{
TMOD=0x01; //定时器0为方式1
TH0=(65536-2000)/256; //给T0赋初值
TL0=(65536-2000)%256; //定时5ms
ET0=1; //使能TO中断
EA=1; //开启总中断使能
TR0=1; //T0开始计数
bbb=100;
ccc=30;
ccc2=40;
ggg=0;
ggg2=0;
i=0;
i2=0;
//aaa=1;//测试
//P2=0xff; //测试
//P1=0x00;//测试
while(1)
{
if(key1==0)
{
aaa=1;
}
if(key2==0)
{
aaa=2;
}
if(key3==0)
{
aaa=3;
}
if(key4==0)
{
aaa=4;
}
if(aaa==1)
{
if(ggg>ccc)
{
ggg=0;
P1=zj1|fj2[i2];//1 1正 2反
//P1=zj1|zj2[i2];//2 1正 2正
//P1=fj1|zj2[i2];//3 1反 2正
//P1=fj1|fj2[i2];//4 1反 2反
i++;
if(i>8)
{
i=0;
}
}
if(ggg2>ccc2)
{
ggg2=0;
// P1=0x00;
P1=zj1|fj2[i2];//1 1正 2反
//P1=zj1|zj2[i2];//2 1正 2正
//P1=fj1|zj2[i2];//3 1反 2正
//P1=fj1|fj2[i2];//4 1反 2反
i2++;
if(i2>8)
{
i2=0;
}
}
}
if(aaa==2)
{
if(key3==0)
{
ccc++;
delay(300);
}
if(key4==0)
{
ccc--;
delay(300);
}
if(ggg>ccc)
{
ggg=0;
i++;
if(i>8)
{
i=0;
}
//P1=zj1|fj2[i2];//1 1正 2反
P1=zj1|zj2[i2];//2 1正 2正
//P1=fj1|zj2[i2];//3 1反 2正
//P1=fj1|fj2[i2];//4 1反 2反
}
}
if(aaa==3)
{
if(key3==0)
{
ccc++;
delay(300);
}
if(key4==0)
{
ccc--;
delay(300);
}
if(ggg>ccc)
{
ggg=0;
i++;
if(i>8)
{
i=0;
}
//P1=zj1|fj2[i2];//1 1正 2反
//P1=zj1|zj2[i2];//2 1正 2正
P1=fj1|zj2[i2];//3 1反 2正
//P1=fj1|fj2[i2];//4 1反 2反
}
}
if(aaa==4)
{
if(key3==0)
{
ccc++;
delay(300);
}
if(key4==0)
{
ccc--;
delay(300);
}
if(ggg>ccc)
{
ggg=0;
i++;
if(i>8)
{
i=0;
}
//P1=zj1|fj2[i2];//1 1正 2反
//P1=zj1|zj2[i2];//2 1正 2正
//P1=fj1|zj2[i2];//3 1反 2正
P1=fj1|fj2[i2];//4 1反 2反
}
}
/*
*/
}//w1
}//ma |