When I put a standard red LED with a 100ohm resistor on a gpio (or just between ground and V3) on my black pill, and I connect PA6 to ground with a 10K resistor, analogRead(PA6) returns around 300 when the LED is on, and 0 when it's off. Is 10K not enough for a pulldown?
I don't have any issue with the built in LED on the board.
ADC issue
Re: ADC issue
Checked with bluepill (F103) and blackpill (F411) and no problems. It reads 1-2 with LED connected.
There must be something wrong with your circuit.
If I connected 100 Ohm resistor to GND and then LED and pull down resistor to it, then I got ~150-170 with white, blue and green LEDs and ~350 with yellow and red LEDs, but this is expected as there is voltage loss on this 100 Ohm resistor and it depends on current drawn by LED.
There must be something wrong with your circuit.
If I connected 100 Ohm resistor to GND and then LED and pull down resistor to it, then I got ~150-170 with white, blue and green LEDs and ~350 with yellow and red LEDs, but this is expected as there is voltage loss on this 100 Ohm resistor and it depends on current drawn by LED.
Re: ADC issue
working some numbers
300 / 4096 * 3.3 = 0.24v
Then look at some datasheets
https://downloads.cree-led.com/files/ds/h/HB-C4SMA.pdf
it turns out forward voltage can run from 2-3.8v
TYPICAL ELECTRICAL & OPTICAL CHARACTERISTICS (TA = 25°C) table
given that if the voltage is measured across the 100 ohm resistor, 0.24v isn't after all incorrect
the other thing is to use a large sample time, especially if you are using a higher series resistance to the adc.
300 / 4096 * 3.3 = 0.24v
Then look at some datasheets
https://downloads.cree-led.com/files/ds/h/HB-C4SMA.pdf
it turns out forward voltage can run from 2-3.8v
TYPICAL ELECTRICAL & OPTICAL CHARACTERISTICS (TA = 25°C) table
given that if the voltage is measured across the 100 ohm resistor, 0.24v isn't after all incorrect
the other thing is to use a large sample time, especially if you are using a higher series resistance to the adc.
-
- Posts: 2
- Joined: Fri Jul 19, 2024 1:33 pm
Re: ADC issue
But the 100 ohm resistor is not connected to the ADC pin, only to V3 or another GPIO.
-
- Posts: 142
- Joined: Mon May 06, 2024 1:46 pm
- Location: Germany
Re: ADC issue
Learn to describe your problem correctly, so everyone has the same understanding!alexanderpruss wrote: Mon Jul 22, 2024 5:54 pm But the 100 ohm resistor is not connected to the ADC pin, only to V3 or another GPIO.
From your start posting
it can be this:alexanderpruss wrote: Fri Jul 19, 2024 3:17 pm When I put a standard red LED with a 100ohm resistor ... (or just between ground and V3) on my black pill, and I connect PA6 to ground with a 10K resistor ...