Pin 0 in series with an LED in series with a resistor (380 ohms) and to the ground.
To check if the LED is on, I took the negative lead and draw a wire to pin 1.
Now when the pin 0 is given HIGH, the LED turns on.
Then I digitalRead pin 1 to see if the LED is on, it returns a LOW.
I also checked both ends of LED (while switched on) using pin A0, both sides being at a level “1024”.
Why is the negative end of LED (turned on) give a LOW on digitalRead?
You can define a Boolean variable that holds the state of the LED instead of checking the state with digitalRead. if you still want to read the value, you should connect pin0 to pin1 and connect a pulldown resistor(abt 5k) across ground and pin1.
My system design is concerned with the failure of LED. How to check if my LED isn’t burnt out and the circuit isn’t broken?
Why do you want to check if the led has failed/burnt out? It isn’t likely if you use proper current limiting resistors
If you still want to check if the led has failed, check if it is glowing or not. Else you can check the voltage drop across the led using the analogue input pin. If the led burns out ,it will open the circuit and the A0 voltage will rise. You can detect that in your code (add a range of values to be accepted).this is just my idea am not sure if it will work.
LED can be replaced with any component tomorrow. My question is why digitalRead on the negative lead of the LED doesn’t give a HIGH?
What component do you want to replace the led with. This idea of mine works on the fact that the resistance of the current limiting resistor is higher than the resistance of the led.if the other component causes a voltage drop across itself near the supply voltage(3.3v) it can’t be detected.pls reply with a proper explanation of what exactly want to make. The negative lead of the led does’nt give a HIGH because it is connected to ground.also make sure to add pull-up/pulldown resistors to digitalRead pins.