正反转可控直流电机

源代码在线查看: i

软件大小: 31 K
上传用户: yf20082008
关键词: 可控直流 电机
下载地址: 免注册下载 普通下载 VIP

相关代码

				#include
				#include
				#define uchar unsigned char
				#define uint unsigned uint
				sbit key1=P2^0;
				sbit key2=P2^1;
				sbit key3=P2^2;
				sbit led1=P1^0;
				sbit led2=P1^3;
				sbit led3=P1^6;
				sbit a=P2^6;
				sbit b=P2^7;
				void delay(uchar z)
				{
					uchar x,y;
					for(x=z;x>0;x--)
						for(y=112;y>0;y--);
				}
				void main(void)
				{
					led1=1;led2=0;led3=1;
					while(1)
					{
						
						if(key1==0)
						{
							delay(5);
							while(key1==0);
							a=0;b=0;
							led1=1;	
							led2=0;
							led3=1;
						}
						if(key2==0)
						{
							delay(5);//while(key2==0);
							a=0;b=1;
							led1=0;	
							led2=1;
							led3=1;
						} 
						if(key3==0)
						{	
							delay(9);
							while(key3==0);
							a=1;b=0;
							led1=1;	
							led2=1;
							led3=0;
						}  
					}
				}			

相关资源