Requirements: LEDs and buttons share the IO port of an MCU
Goal: When the button is pressed once, the light is on, and it stays on until the corresponding button is pressed again, and the light is off
The picture I draw now cannot meet this requirement, because when the light is on, the IO port of the MCU is high, and both sides of the button are high, and it is impossible to give a signal to the MCU. How can you design to meet the demand without adding other types of components?
Cheyanne 發表於 August 6, 2020
You explain first, what kind of operation is required, that is, when the switch is pressed, MCU_IO goes from HIGH to LOW??
Jaylah 發表於 August 6, 2020
Remove 3K, set the R value according to the actual lamp design resistance value, and exchange the LED with the switch. IO is initialized to high impedance or high level. When the button is pressed, the LED is on and the IO outputs low level. The LED is always on. When the button is pressed again, the IO outputs high level and the LED is off. Personal analysis. No verification. for reference only
Kaliyah 發表於 August 6, 2020
See if this design is feasible?