bianchi77
Advanced Member level 4
- Joined
- Jun 11, 2009
- Messages
- 1,313
- Helped
- 21
- Reputation
- 44
- Reaction score
- 20
- Trophy points
- 1,318
- Location
- California
- Activity points
- 9,442
Guys,
How to control motor with sensor ?
I'm using AT89LV55 and Keil
with this code the motor always "ON" even the sensor is OFF
sensor active H and Motor active L
Thanks
How to control motor with sensor ?
I'm using AT89LV55 and Keil
with this code the motor always "ON" even the sensor is OFF
sensor active H and Motor active L
Thanks
Code:
#define TRUE 1 //some defines
#define FALSE 0
// Define the keypad start
sbit sensor1=P0^0; // Sensor 1
sbit motor1=P0^1; // Motor 1
void main()
{
motor1=TRUE;
sensor1=FALSE;
while(1)
{
if (sensor1=FALSE) // if there's nothing at the sensor
{
motor1=TRUE; // deactivated the relay to turn off motor
}
else
{
motor1=FALSE; // activated the relay to turn on motor
}
}//end of while
}