2 ports 4 buttons

  • Tutorial
Hi geektimes . One priblu came to me from China, which I found on the network, and when I looked, I found a very interesting part for myself, here it is:

image

Since almost all the ports of the microcontroller are occupied, the Chinese have acted very slyly to save ports, you can evaluate the level of tricks yourself.

How it works?
For the first port we turn on the pull-up resistor (pull-up) and check the status on the port, if the " DOWN " button is pressed , we get a low logic level. Exactly the same picture with the " SET " button , only pull-up is done already for the second port.

To read the " OK " button , we translate the second port into a pull-up, and the first one is set as an output, and we make a low logic level. In this case, when you click " OK", the current will flow from the second port turn the diode to the first, thus, when reading the state of the second port, we get a low logic level. The same situation with the definition of pressing the" UP " button - pull-up on the first port, the second set to output and set a low logic level. When you press the " UP " button, the current will flow through the diode to the second port, and accordingly, the first port will have a low logic level.

All my publications are on geektimes.

Also popular now: