Hello,
I defined one of the GPIO's of the microcontroller as tristate input, and its connected to an Active-low switch.
When the switch is being pressed, the GPIO's voltage turns from High to Low, and when the switch is released, the GPIO's voltage turns back to High.
So far, I didnt care for how long the switch was pressed, but now i was asked that when the switch is pressed for 3 seconds (or more), then I'll execute a ceratin command.
Do you have any suggestions of how doing it?
I thought that when the switch is pressed, i'll check the GPIO's voltage every 100mSec and if it remains LOW for 30 '100mSec checks' (meaning for 3 seconds), then I'll execute the command.
I defined one of the GPIO's of the microcontroller as tristate input, and its connected to an Active-low switch.
When the switch is being pressed, the GPIO's voltage turns from High to Low, and when the switch is released, the GPIO's voltage turns back to High.
So far, I didnt care for how long the switch was pressed, but now i was asked that when the switch is pressed for 3 seconds (or more), then I'll execute a ceratin command.
Do you have any suggestions of how doing it?
I thought that when the switch is pressed, i'll check the GPIO's voltage every 100mSec and if it remains LOW for 30 '100mSec checks' (meaning for 3 seconds), then I'll execute the command.
Last edited: