Archive | Push Button RSS for this section

DMP Photo Booth: The Trigger

After several days of trying to make sense of the POSIX Terminal Interface, I’ve come to a lull in development. Today I’ve been looking through the code, fixing problems as I find them. One major problem I noticed: there is no documentation on the actual trigger.

I decided to draw a schematic for the trigger:

Trigger Schematic

The Concept

It’s pretty basic: a button and 5 lights. My general concept for the trigger was inspired by the starting light at a race. It counts down from 5: at 5, the top light is lit, at 4 the top two are lit and so on. As the count reaches 1, all lights are lit and the camera module calls capture(), starting the race.

If an error needs to be displayed, the 5 lights act as the first 5 bits in a byte (it can display 0 – 31). The lights flash a binary number indicating the error that occurred. Practically, what will happen is a user will go tell a grownup that “it’s blinking”. But an operator can see the code and interpret the problem. The codes will be high level; actual error messages will get printed to the console. However, I felt it important to give negative feedback on the trigger so users don’t just sit there wondering why nothing is happening.

Room for Improvement

There are two things up for consideration at the moment. The first thing is the light configuration. I had a racing starting line in mind, but it turns out that the starting line of a race looks like this:

I guess I’m just not much of a racing fan… I may change the lights to match, or I may abandon my metaphor. Either way, this is a low priority issue.

Secondly, I am considering implementing an audio element to this. If I add this, the trigger will play a low-pitched tone on red lights, and a higher pitched tone on green. This will make it more obvious to the user that a countdown is happening. If you’ve ever played Mario Kart, think the noise the light makes at the starting line.

The only reason I haven’t already added this is because I’m concerned it may be annoying.

Learning to Arduino: Push Button

Getting a little less abstract today, I’d like to talk about the Push Button. Sorry, that doesn’t have a fancy name. Try to contain your disappointment.

The push button is actually very simple in theory. Most push buttons have four contacts. Two of these contacts are connected at all times, and there is a normally open switch between the two “wires”.

push_button1

When the button is pressed, the contact closes. The tricky part comes in the implementation.

pinMode(pin, INPUT): REVEAL YOUR SECRETS!

You’d be yelling too if you’d spent as much time as I trying to figure this out.

A typical application of the Push Button, is in an arduino device. Arduinos have multiple digital pins that can be configured as inputs or outputs. Google Arduino Push Button Tutorial, and you’ll find several tutorials that suggest you implement something similar to this:

push_button

The thing that nobody is talking about: what is the voltage of the digital pin in input mode. This is the thing I’ve been spending the last few hours trying to figure out: how does this work? If the voltage is 0, nothing should happen when the button is not depressed. If the voltage is 5, then nothing should happen when the button is depressed. It turns out, according to my multimeter, that this pin is actually very slightly less than 0 Volts.

As you can see from my diagram, the digital pin is connected to the switch, and the opposite end is connected to a 10K Ohm resistor to ground. On the other side of the switch is 5 Volts. When the switch is open, electrons flow from ground (0 Volts) to the input pin (slightly less than 0 Volts) and digitalRead() returns LOW. When the Push Button is depressed, electrons flow from the input pin (slightly less than 0) to the 5 Volt pin, and digitalRead() returns HIGH.

All is again well in the world.

%d bloggers like this: