Turn-key PCB assembly services in prototype quantities or low-volume to mid-volume production runs

Single I/O pin – double function

There are many situations when you simply run out of I/O pins on microcontroller. For new project you can always select different microcontroller with more pins or ad I/O expander. If you have project running on Raspberry Pi and almost all your pins are busy, then you should try to go smart way. Emilio faced this problem when he needed to add LED indicator and button to his existing project, but there were only single free pin available. So he thought that functionality could be achieved with single pin quite easy.

single_pin_dual_operation

He attached LED to power supply via current limiting resistor. Then using same pin he added push button to ground through another resistor. The rest depends on how program controls that pin. In this case Python script simply runs loop every second where 200ms is used to turn LED another portion of time-frame is used to detect button switch and some sort of debounce. Button is used to shut down Raspberry Pi after it is pressed for longer than 5 seconds. Same technique can be easily used on any microcontroller as well.

[..Source link..]

Bookmark the permalink.

Leave a Reply