LED ON/OFF Using Switch
In this tutorial we On and Off LED using Switch button in 8051.
Connections:
Program:
#include <reg51.h>
sbit LED = P1^1;
sbit sw = P1^2;
void delay(int t)
{
int i = 0;
for(i=0;i<12750*t;i++)
{
}
}
void main()
{
if (sw == 0)
{
LED = 0;
delay(2);
}
else
{
LED = 1;
delay(2);
}
}
Comments
Post a Comment