You are on page 1of 1

#include<reg51.

h>
sbit SW_1 = P2^6; //connecting switch 1 to the port 2 ,pin 6.
sbit SW_2 = P2^7; // connecting switch 1 to the port 2 ,pin 7.
sbit MTR = P1^0; // from this pin we get the signal that is to be fed to the bas
e
void main()
{ int x;
while(1)
{
if(SW_1==0 & SW_2==0)
{
MTR=1;
for(x=0;x<150;x++);
MTR=0;
for(x=0;x<600;x++);
}
if(SW_1==0 & SW_2==1)
{
MTR=1;
for(x=0;x<300;x++);
MTR=0;
for(x=0;x<300;x++);
}
if(SW_1==1 & SW_2==0)
{
MTR=1;
for(x=0;x<600;x++);
MTR=0;
for(x=0;x<150;x++);
}
if(SW_1==1 & SW_2==1)
{
MTR=1;
}
}

You might also like