Muhammad.Saad
Newbie level 6
- Joined
- Mar 11, 2014
- Messages
- 12
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Location
- Islamabad, Pakistan
- Activity points
- 105
Hi
I am new to mcu. I want to make a project for controlling two leds. I am using PCW (Pic c compiler)Please help me to correct my code to on/off relay through potentiometer reading(0 to 5v). I need to on the relay when voltage is under 1.5v and above 4.5v. here is my circuit.I need to operate rely for under and over voltage limitations.
lower limit is 1.5v
upper limit is 4.5 v.
Here is code
Looking forward for reply
Looking for help
I am new to mcu. I want to make a project for controlling two leds. I am using PCW (Pic c compiler)Please help me to correct my code to on/off relay through potentiometer reading(0 to 5v). I need to on the relay when voltage is under 1.5v and above 4.5v. here is my circuit.I need to operate rely for under and over voltage limitations.
lower limit is 1.5v
upper limit is 4.5 v.
Here is code
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #include <main.h> #fuses NOWDT #fuses NOLvP #fuses HS #fuses NODEBUG #include<stdio.h> #include<STDLIB.H> #use delay(clock=11059200) #DEFINE relay_on 1 #define relay_off 0 #fuses HS,WDT unsigned int8 relay,adcvalue, LOWERLIMIT, UPPERLIMIT; void main(void) { setup_adc( ADC_CLOCK_INTERNAL); setup_adc_ports( ALL_ANALOG ); ( input(PIN_A0)); set_adc_channel(0); relay = read_adc(); LOWERLIMIT = (5*relay*100/1023); UPPERLIMIT = (5*relay*100/1023); if (LOWERLIMIT < 2) output_low(PIN_C0); Else output_high(PIN_C0); if (UPPERLIMIT <= 4) output_high(PIN_C0); else output_low(PIN_C0); }
Looking forward for reply
Looking for help
Attachments
Last edited by a moderator: