Skip

I know what I want, but not what I need
August 24, 2014 8:10 PM   Subscribe

ElectronicsFilter: I would like to construct a box with 4 lights that work on a timer. I know lots about software, and little about hardware, please help steer me in the right direction.

I'd like to learn a little bit more about electronics, and as such, I have come up with a project that I'd like to figure out how to implement, but I'm not sure where to start.

Basically, I'd like a little battery powered box with 4 lights (probably LEDs) and a button (probably a momentary push button switch).

When I press the button, I'd like the first light to activate (light up, maybe blink) for 30 seconds, then the next for 30 seconds, etc., basically measuring out two minutes in 30 second intervals. I don't want any kind of digital (i.e. numeric) display. The intervals do not have to be variable at all (I know that for my purposes, I will always want 2 minutes divided into 4 sections).

I can do this on my smartphone in seconds, but I'll be using the device in situations where I'd rather not have my phone with me.

My question: What is the cheapest/easiest way for a total beginner to make this happen? Assume that I own a soldering iron and nothing else that would be required. I also know the basic science behind resistors, capacitors, and transistors, but not so much about "this DigiKey part number is a doodad that will make your whoozits fizzbang".

If the right answer is "Arduino", or "Raspberry Pi", feel free to just let me know that and I'll start learning what I need to make things work within those platforms. But I also feel like those would be total overkill for what I'm trying to do.
posted by sparklemotion to Sports, Hobbies, & Recreation (13 answers total) 4 users marked this as a favorite
 
If you're a software person then the answer is arduino. Plus 4 LEDs and 4 330-ohm resistors to put in series. If you want brighter lights (more than about 40 mA per LED) then you also want 4 n-channel MOSFETs to use as drivers, so you can source current to the LEDs directly from the power rails instead of through the I/O pins.

All of this is cheap at digikey. If you don't want to learn to sift through 10,000 pages of resistor options I highly recommend Sparkfun and Adafruit, who have done it for you in exchange for a moderate price increase.
posted by range at 8:32 PM on August 24 [1 favorite]


My question: What is the cheapest/easiest way for a total beginner to make this happen

Doing this with an Arduino would be easiest. That platform and community is centered around projects like yours.

I don't think it's overkill, either. If a microcontroller is the cheapest and easiest way to get the job done, it's not overkill. Some of the more usual Arduinos are can be expensive, but if your code is simple, you can transfer it to one of the cheaper ones (though I'd still recommend getting something like a Uno to start out with) or wire up the microcontroller yourself.

A Raspberry Pi wouldn't be as good, since they're not really designed for projects like yours, and they can also be fussier (SD card corruption, etc).

Caveat: I'm only a little bit further a long than you, skill wise. I'm by no means an expert on this.
posted by cosmic.osmo at 8:35 PM on August 24


(I should note that what you need to do is easily handled by the cheapest and smallest Arduino, the nano. If you really want to keep the cost down, it's pretty easy to find nano boards made by Chinese fabricators on eBay for about 6 bucks. I buy about 200 of these a year and I don't think we've ever had a dud)
posted by range at 8:37 PM on August 24


Easy way: Just use an Arduino. For your use it's a bit overkill, but it's by far the easiest way.

Harder way: Use a 558 quad timer IC (a variant of the ubiquitous 555 chip). You set the delay times using resistors and capacitors. Harder to figure out, and will use more external components, but less "overkill".
posted by neckro23 at 8:46 PM on August 24


Wow, ignore what I said about the 558 -- apparently they're not really made anymore. You'd have to use two 556 chips (dual 555s) instead. So, it's even less worth the effort.
posted by neckro23 at 8:50 PM on August 24


Actually, it would probably be better to have a single timer, a counter, and an output decoder. That way you're not trying to sync up independent timers trying to minimize overlap, etc.

The timer clocks off 30s ticks.
The counter counts 00 01 10 11.
The decoder translated counter output to 0001 0010 0100 1000.

Then you need something else to shut it down when it's done. Maybe use a 3 bit counter and have the MSB stop the timer?

Sparklemotion, please indicate whether you want to go in the pure hardware direction. I'll be happy to help you with circuit design, etc. (Also I know Digikey inside out.)
posted by ryanrs at 8:54 PM on August 24


I'd like to go pure hardware if possible. Coding something this trivial seems like cheating, and the fact that it might be tricky in hardware is part of why I want to demystify this world for myself.

I understand that that might be getting away from my stated goal of "the easiest way", but I like the appeal of learning from first principles a little.
posted by sparklemotion at 9:15 PM on August 24


Even cheaper than an Arduino, but definitely up to the task, is the $10 MSP430 LaunchPad programmed with the Wiring/Arduino compatible Energia package. It already has two out of the three LEDs you need on board, and the pushbutton.

(I use one as a [self link, sorry] pomodoro-ish thing, with no additional hardware.)
posted by scruss at 9:24 PM on August 24


Use a CMOS 4-bit shift register and a 555 timer for the clock. About 10 cents each. When you press the button you parallel load the shift register with the hardwired value 0001. When you release the button, the 555 timer shifts the bits every 30 seconds and recirculates the last bit back to the first. This continues forever until power is removed. You don't even need a button. You could have the initial load occur when power is applied.
posted by JackFlash at 9:28 PM on August 24 [1 favorite]


Yes, JackFlash's implementation is simpler. If you want it to stop the lights after 4 cycles, you don't even need to detect the end state. Just let the last one bit fall out of the shift register. Then you're shifting zeros and all lights will be out.

I'm thinking LMC555 for the timer and 74HC194 for the shift register.

If you want to blink the lights too, I suggest a second 555 timer pulsing the LED common power supply. Tweak the freq and duty cycle to suit whatever visuals you have in mind.

Next up: what kind of lights do you want, and how do you plan to power this thing?
posted by ryanrs at 9:56 PM on August 24


If this is just going to light up 4 indicator LEDs (as opposed to more powerful LEDs like in a flashlight), then you can power the whole thing on 1 or 2 AA batteries and they will last so long you will never need to change them.

Amusingly, the choice of 1 or 2 AA batteries comes down to your soldering skills. The sexy ultra low power single-cell power supplies tend to only be available in surface mount packages. If you insist on breadboarding it, you might have to settle for 2 batteries.
posted by ryanrs at 10:22 PM on August 24


Another think to think about is timing accuracy. Is 1-2% accuracy good enough? This is about all you're going to get with a 555.

The next step up, a quartz crystal, takes you to straight to 0.01% accuracy, but at the cost of 4x the circuit complexity. The dollar cost is small, but it will involve a circuit that doesn't much like being build on a breadboard. Also you will be hard pressed to debug it with a multimeter. Do you have a scope handy?

Note that the 1-2% accuracy figures aren't about immediate accuracy right after you assemble the device. It's a given that you will be able to dial it in precisely when making it. The problem is more about what happens 6 months later, when you're outside and it's 50% more humid and the temperature is 20 C higher. How's your accuracy then? Will you care if the 2 minute timer is 2 seconds off?

As with any electronic project, there are many tradeoffs between complexity, cost, power consumption, and performance. We can make this 4 LED, 1 button device arbitrarily complicated and teach you a lot about electronic design in the process.
posted by ryanrs at 11:49 PM on August 24


My approach would be to throw together a shrimp (which is basically a super cheap Arduino clone)

The programming of it is super easy since you know software.

The hardware side is complicated enough to make it interesting, but not enormously daunting.
posted by Just this guy, y'know at 4:14 AM on August 25


« Older Eating at 'Cheesecake Cafe' an...   |  My boyfriend would like some r... Newer »

You are not logged in, either login or create an account to post comments



Post