PIC controller resets when connected to 12V solenoid valve.

jayanthd

Joined Jul 4, 2015
945
You should not do like that. If you have button press detect and some other input reading code then if the micro is executing the Delay_ms(1000) function then button press and inputs will not be read at that time. This is known as blocking code. You have to create a timer interrupt of say 500 ms and then use a counter which when becomes 2 (500 ms * 2 = 1 sec) then set a flag is ISR and then in main loop check if this flag is set and if flag is set then read the ADC input and clear the flag.

If values are fluctuating then take 20 samples and then take average. See if this stabilizes the fluctuation.

I assume the question you are asking about the ADC is not related to the original question of this thread and so I feel you have to open a new thread and ask your new question there.
 
Top