Hi everyone. I am in trouble. Please help me as fast as you can. I am using LM324 comparator IC to compare the 12V battery voltages. Now I am giving 12v DC of Adapter to the Vcc of LM324 and 0v to Ground. I made 9v voltage from adapter using resistors and gave it to the Vref of LM324 means pin no 2. And i Connected +ve terminal of my 12v battery(which i want to connect to the Inverter) to the Vin terminal of LM324 which means pin no 3. LM324 works properly. It means whenever Vref<Vin then Vout(pin no 1 of LM324)= 11.89(this value is always fluctuating). And whenever Vref>Vin then Vout= 0v.
But I am facing the problem
pinMode(12,INPUT); // I connect output pin of LM324 at digital pin no 12 of arduino UNO
int state = digitalRead(12);
if (state == HIGH)
Serial.println(“12 is high”);
else if (state == LOW)
Serial.println(“12 is low”);
when i am using this code to check the state of output of LM324 if the answer always fluctuate between HIGH and LOW when Vref<Vin, also it happens in Vref>Vin.
So, this Fluctuation problem of arduino became Headache for me. I know that I have to minimize the voltage level and keep it at 5v, and i had done that but still answer is fluctuating. Please Help fast guys. I am in big trouble .