Posts | Comments

Planet Arduino

Archive for the ‘one button’ Category

When building projects with a simple goal in mind, it’s not unheard of for us to add more and more switches, buttons, and complexity as the project goes through its initial prototyping stages. Feature creep like this tends to result in a tangled mess rather than a usable project. With enough focus, though, it’s possible to recognize when it’s happening and keep to the original plans. On the other hand, this single-button project with more than one use seems to be the opposite of feature creep. (YouTube, embedded below.)

[Danko]’s project has one goal: be as useful as possible while only using a single button and a tiny screen. Right now the small handheld device can be used as a stopwatch, a counter, and can even play a rudimentary version of flappy bird. It uses an Arduino Pro Mini, a 64×48 OLED screen running on I2C, and has a miniscule 100 mAh 3.7V battery to power everything. The video is worth watching if you’ve never worked with this small of a screen before, too.

Getting three functions out of a device with only one button is a pretty impressive feat, and if you can think of any other ways of getting more usefulness out of something like this be sure to leave it in the comments below. [Danko] is no stranger to simple projects with tiny screens, either. We recently featured his homebrew Arduino calculator that uses an even smaller screen.

Sometimes less is more. This is especially true when dealing with microcontrollers with limited I/O pins. Even if you have lots of I/O, sometimes you are need to pack a lot into a little space. [Hugatry] was inspired by the simple interface found on a lot of flashlights: one button. Push it and it turns on. Push it again, and it switches modes. You cycle through the modes until you finally turn it back off. One button provides mutliple functions. The question is how can you use a power switch as an I/O device? After all, when you turn the power off, the microprocessor stops operating, right?

[Hugatry’s] answer is quite simple. He connects a resistor/capacitor network to an I/O pin (or multiple pins). When the processor turns on initially, the pin will read low and the capacitor will charge up. If you turn the power off, the CPU voltage will fall rapidly to zero, but the voltage on the capacitor will discharge slower. If you wait long enough and turn the power on, there’s no difference from that first power on event. But if you turn the power on quickly, the capacitor voltage will still be high enough to read as a logic one.

What that means is that the processor as part of its start up can detect that it was recently turned off and take some action. If it remembers the previous state in nonvolatile memory, you can have the code cycle through multiple states, just like a flashlight. You can see a video of the setup, below.

[Hugatry] included some simple Arduino code that illustrates the concept. However, the technique is simple enough that you can adapt it to other projects easily.

Think one button isn’t enough to do anything interesting? Think again. Then again, Amazon probably has a patent on things with one button.


Filed under: Arduino Hacks, Microcontrollers


  • Newsletter

    Sign up for the PlanetArduino Newsletter, which delivers the most popular articles via e-mail to your inbox every week. Just fill in the information below and submit.

  • Like Us on Facebook