Blue bridge cup LED, buzzer, relay control

声明:
usigned char L1,L2,L3,L4;	
定时扫描:
P0=~(8*L4+4*L3+2*L2+L1);P2=0x80;P2&=0X1f; //点亮LED
P0=0xff;P2=0x80;P2&=0X1f;//熄灭所有led灯
调用: 
L1=1;L1亮    L1=0; L1灭

Related reference articles:

L2 is in the second place of P0 2^(2-1)=2; L6 is in the sixth place of P0 2^(5-1)=32; the program of the second    simulation game of the 14th Lanqiao Cup MCU

声明:
usigned char led=0xff;	
定时扫描:
P0=led;P2=0x80;P2&=0X1f; //点亮LED
P0=0xff;P2=0x80;P2&=0X1f; //熄灭所有led灯
调用: 
led&=0xfe; 点亮L1;  led|=0x01; 熄灭L1;

Related reference articles: 

 http://t.csdn.cn/oG2sY

The Ninth Lantern Festival - Timed Polling, State Machine, Array

声明:
usigned char Buzz,Relay;	//蜂鸣器和中继
定时扫描:
P0=(128*Buzz,16*Relay);P2=0xA0; P2&=0X1f; //开启
P0=0X00;P2=0xA0;P2&=0X1f;   //关闭
调用: 
Buzz=1; 蜂鸣器响  Relay=0; 关闭中继

  Buzz is at the seventh position of P0 2^(7-1)=128; Relay is at the fifth position of P0 2^(5-1)=16;  

Guess you like

Origin blog.csdn.net/qq_56095985/article/details/130037582