R2R ladder connects multiple buttons to one ADC pin

If you’ve run out of I/O pins on a project and need a way to add user input you can find a slew of port expanders that work with various communications protocols like I2C and 1-Wire. But if you just want to add in some buttons without reaching for an extra IC you’ll love this hack. [John Boxall] shows how to add four buttons using one ADC pin.

The concept is nothing new. The buttons make up an R2R resistive ladder. When one of them is pressed, it completes the circuit for a voltage divider. The results are measured by the analog-to-digital converter of an IC to tell which button was pressed. The difficult part is calculating the resistor values. [John] is using eight resistors made up of just two different values. Every button and every combination of buttons has a unique voltage result which can be discerned by the chip. He even made a truth table so you don’t have to.

The example circuit seen in the video after the break uses an Arduino. But this concept is directly applicable to any microcontroller. And it should be quite easy to use an ADC interrupt to drive all of the button-read events. [Read more…]

Reading diodes to create a thermal imaging system

[Udo Klein] was working with some 1N4148 transistors and was interested in the specs relating to their performance at different temperatures. The forward voltage actually changes quite a bit depending on temperature and wondered if this could be reliably measured. He hacked his own LED shield for the Arduino to use as a 1×20 thermal imaging system.

The screenshot above is mapping the voltage measurements from a row of diodes (see the video after the break to get the full picture). He’s holding an ice pack over the row of diodes and observing the change. The on-screen display is facilitated by a Python script which is pulling data from the Arduino. Since there aren’t enough analog inputs to read all twenty diodes separately they have been multiplexed. Four I/O pins each enable five of the diodes, readings are taken with five analog inputs before moving on to the next set.

What can this be used for? That is precisely the wrong question… sometimes you’ve just got to go where your curiosity takes you. [Read more…]