Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

Motor status based on moisture sensor using 8051

Status
Not open for further replies.

sujeethaa

Junior Member level 3
Joined
Nov 18, 2012
Messages
26
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Location
bangalore
Activity points
1,464
hi all

<60=motor on
>75=motor off
bet 60 to 75 = previous status

how can i write the c code for this status

thanks in advance
 

Joined
Jul 25, 2012
Messages
1,192
Helped
170
Reputation
340
Reaction score
161
Trophy points
1,343
Activity points
0
see this link https://www.edaboard.com/thread272349.html

Code:
#define MOTOR PORTB.0

unsigned int adc_val;
unsigned int prev_state;

if(adc_val < 60) {

	MOTOR = 1;
	prev_state = 1;
}
else if(adc_val > 75) {
	
	MOTOR = 0;
	prev_state = 0;

}
else if((adc_val >= 60) && (adc_val <=75)) {
	MOTOR = prev_state;

}
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top