My project involves detecting from a Raspberry Pi Pico 2 W whether the USB port of my TV is on or off.
So, I decided to create a voltage divider to reduce the voltage from 5V to ~3V with a current of ~10μA, and I made the following circuit:
But if I try to execute the following code (MicroPython), I only get a state change (0 -> 1) the first time I turn on the USB, then nothing happens.
Code: Select all
from machine import Pin
INPUT_3V = Pin(15, Pin.IN)
current_state = INPUT_3V.value()
while True:
if current_state != INPUT_3V.value():
current_state = INPUT_3V.value()
print("Input state changed to", current_state)
- if I turn off the USB, there is no state change
- if I turn on the USB, I get the following logs:
Code: Select all
Input state changed to 0 Input state changed to 1
Thank you in advance for your help!