How to control motor with sensor ?

Status
Not open for further replies.

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
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
}
 

hi what a pblm occured in your coding?
what type of sensor you r using?
and cgheck ur coding
if (sensor1=FALSE) is an assignment statement
write if (sensor1==FALSE) and compile.

with regards
 

hi what a pblm occured in your coding?
what type of sensor you r using?
and cgheck ur coding
if (sensor1=FALSE) is an assignment statement
write if (sensor1==FALSE) and compile.

with regards

I'm using PIR sensor..
 

use adc channel.
 
Last edited:

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…