Hello
I have three button's and two light's and one Fan. I want to make light1 ON if switch 1 is pressed otherwise turn of light 1. turn ON light2 ON if switch 2 is pressed otherwise turn of light 2. turn ON Fan 1 if switch 3 is pressed otherwise turn of Fan 1.
I just compiled program. there is no error. I am not sure Is my program doing that work?
I have three button's and two light's and one Fan. I want to make light1 ON if switch 1 is pressed otherwise turn of light 1. turn ON light2 ON if switch 2 is pressed otherwise turn of light 2. turn ON Fan 1 if switch 3 is pressed otherwise turn of Fan 1.
Code:
#include<89v51rx2.h>
sbit Light1 = P1^0; /*set bit P1^0 to Light 1*/
sbit Light2 = P1^1; /*set bit P1^1 to Light 2*/
sbit Fan1 = P1^2; /*set bit P1^2 to Fan 1*/
sbit Switch1 = P2^0; /*set bit P2^0 to Switch 1*/
sbit Switch2 = P2^1; /*set bit P2^1 to Switch 2*/
sbit Switch3 = P2^2; /*set bit P2^2 to Switch 3*/
#define ON 1
#define OFF 0
#define Switch_Closed 1
#define Switch_Open 0
void main (void)
{
while (1)
{
if(Switch1 == ON)
{
Light1 == ON;
}
else
{
Light1 == OFF;
}
if(Switch2 == ON)
{
Light2 == ON;
}
else
{
Light2 == OFF;
}
if(Switch3 == ON)
{
Fan1 == ON;
}
else
{
Fan1 == OFF;
}
}
}
I just compiled program. there is no error. I am not sure Is my program doing that work?