0% found this document useful (0 votes)
3 views2 pages

Microcontroller LED Control Code

Uploaded by

honggianghi0161
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Microcontroller LED Control Code

Uploaded by

honggianghi0161
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

wanvnuawner

10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

#include <REGX5S2.H>

sbit btnON P2*4;


sbit btnOFF P25;
sbit led = P21;
void main(void)

led = 0. //Turn off led at beginning


btnON = 1; //Default, button is High
btnOFF = 1; //Default, button is High

while(1)
{
if(btnON==0) //check if btnON is pressed?
{
led = 1;
while(btnON==@); //wait till stop pressing
}
if(btnOFF==0) //check if btnOFF is pressed?
{
led = 0;
while(btnOFF==) ;
}
//Do some other things here....
WN eveeee

You might also like