Introduction: The Smart, Stealth LED Blinkenlight

My girlfriend has a nice old-school Schwinn Collegiate 5-speed bike. I would like her to be safer when we ride at night but I also wanted to maintain the vintage look of the bike so I decided to build a bike light for her. My goals are as follows:

- The light shall not affect the "stock" look of the bike.
- The light shall operate only when it's dark enough to be effective.
- The light shall operate automatically when the bike is in use and for around 30-60 seconds afterward.
- The light shall blink to enhance visibility at night.
- The battery on the light shall last "indefinitely" when not in use.
- The light shall efficiently utilize the battery's power when in use.
- The electronics of the light shall be reasonably weatherproof -- at least enough that road spray will not affect operation.

Based on that, I made the following initial design decisions:

- The light will use an existing bike reflector to maintain the stock look.
- The battery type will be a 9V rectangular battery.
- The light will use 3 2-volt red LED's for a 6 volt voltage drop. This will additionally allow a 8.4V rechargeable battery to be used in place of the 9V.
- A wire-through-a-spring will be used to detect vibration indicating the bike is in use. The spring will wiggle when the bike is jostled, making electrical contact between the wire and spring.
- A capacitor discharging through a resistor will be used to time power usage on the light for 30-60 seconds.
- A 555 timer will be used to provide make the lights blink.

P.S. In case you're wondering, I used EAGLE (the circuit design package from CadSoft) to lay out the circuits.

Step 1: Make Some Initial Design Decisions.

I had originally considered using a low-power 555 (the TS555) which claims a low operating current of around 150 micro-amps (0.00015 amps) at 9 volts. I had used a circuit almost identical to this one in project. If it was light outside, the light sensor D1 would have low resistance (around 100 ohms) and the reset pin would be near 0 volts, so the 555 would stay reset, keeping the output low. If it was dark, D1 would have high resistance (as much as 10 megohms) and R1 would pull the reset pin to nearly 5 volts and the 555 would run normally, blinking the lights.

However, even with 150 micro-amps all the time, a 9 volt battery with a capacity of around 540 milliamp-hours would last 3,600 hours -- about 5 months. I'd hate to install a brand new battery, use the bike a couple times, and have to replace it twice a year.

One option was to use a switch, but I wanted to make the light automatic.

Step 2: Design a Night-time Vibration-sensitive Circuit.

I figured I'd do an experiment to see if this circuit was any better. The idea is that if C1 is discharged and vibration switch S1 is off (no vibration) then virtually no current will flow through Q3. I measured the battery current (actually, using a 5V power supply, but it's rather irrelevant) with S1 open and C1 discharged. With a high-precision meter, I measured no current. Just for kicks I put in a 100 ohm resistor and measured 0 volts across it so I stepped way up to a 100,000 ohm resistor and managed to measure 0.0004 volts -- that's 4 nano-amps of current, so (assuming a battery that never dies on its own) a 9V battery with 540 milli-amp-hours of capacity would last around 15,000 years.

So it's basically no current when not operating.

Since EAGLE didn't have a cadmium-sulfide (CdS) light sensor already, I just used a photodiode for D1 instead -- it's really a CdS cell, though. The CdS cell has a high resistance in the dark (over 100 kilohms) and a low resistance when it's light (under 200 ohms).

Anyway, when S1 is pulsed on (at this time I just have a couple bare wires I tap together) the current draw in daytime is around 230 microamps. So riding around in the daytime, one can expect no less than (540 mAH / 0.23 mA) = 2350 hours = 98 days of continuous riding. Since S1 pulses on and off, it is more than that, and probably much more.

The interesting stuff happens at night -- when riding, perverts. Transistor Q1 will turn on, charging C1. Since the DC current gain (called "hfe" on specification sheets) of Q1 is around 150x, the 230 microamps through the base-emitter junction is amplified to about 35 milliamps through the collector-emitter junction and also through capacitor C1. C1 will charge to the full 9 volts in a fraction of a second.

So now, regardless of the vibration switch or night sensor, C1 begins to discharge through R2 through the base-emitter junction of transistor Q2. When C1 is fully charged to 9 volts, R2 limits the current to (V / R) = (9 volts / 10000 ohms) = 0.9 milliamps. However, since Q2 also acts as a DC amplifier with a gain around 150x, the current through it could be as high as 135 milliamps -- much more than is necessary to run the LED's alone, and when run through Q3 as well, the maximum current (again with hfe=150) skyrockets to saturation -- 20 amps is far more than the transistor could handle.

However, what if C1 is almost completely discharged? If it only has 0.1 volts in it, then the numbers work out to 10 microamps, amplified by Q2 to 1.5 milliamps, amplified by Q3 to 225 milliamps. Again, this is maximum current, but since the LED's will only draw 20 milliamps, that's the limiting factor in the current.

I tested the circuit as is and it functioned like I expected: the LED's would light up and stay on if CdS cell D1 is in the dark and S1 is pulsed. The LED's stay on for a while.

Step 3: Add the Blinking Circuit.

On the bottom half of the circuit, I swapped out the simple LED for a 555 timer circuit to make the LED's blink. Using the values I selected for C2, R5, and R6 (using the instructions in the specification sheet for the chip), I get a blink rate of about 4 per second with the LED's being on for 2/3 the time.

The LED's I have are red and have a voltage drop of 2.0 volts each. I decided to put 3 in series since I'm using a 9V battery (but possibly a partly dead battery, or an 8.4V rechargeable). R2 limits the current through the resistors: figuring 9 volts total, 6 volts will drop across the LED's, and about 0.7 volts drop across the collector-emitter junction of Q3, leaving 2.3 volts across R2. Using a 100 ohm resistor, the LED's are driven at around ( V / R ) = ( 2.3 volts / 100 ohms ) = 0.023 amps = 23 milliamps of current.

I got a chance to test the circuit and found that the LED's would blink for more than 10 minutes before slowly fading to nothing. I was shooting for something more like 60 seconds. I decided to reduce the capacity of C1 by a factor of 10. Using a 47 microfarad capacitor yielded a more rational 30 seconds before it got dim and it completely shut off by 90 seconds. I decided about 100 microfarads would be good -- 60 seconds before it got dim and 3 minutes before shutting off completely.

Step 4: Lay Out the Circuit for Wiring.

Since I was using EAGLE, I had access to the board layout functionality. I decided I was going to use the "Manhattan-style board construction" as described in http://www.k7qo.net/manhattan.pdf. Basically this involves starting with a plain copper-clad board and gluing on small pads of insulation-backed copper-cladding that will act as contact points. If it doesn't make sense now, don't worry about it because the pictures in upcoming steps will make it clear.

Using the router, what I was trying to accomplish was simply to orient the components so any "node" in the circuit (that is, any wire in the schematic that goes to two or more component pins) had zero distance. In other words, I was trying to do a rough layout so I could put a single pad for each node and connect all the components to it without using jumper wires.

I didn't bother to carefully select appropriate component packages because I was at first just interested in designing the circuit. The capacitors, therefore, are far larger than the ones I actually used. Further, the battery and LED's (and R4 that limits the LED current) are to be mounted off-board. The switch was represented with a 2-pin connector. Finally, I decided that the plain copper-clad board I was going to use as a base should be connected to battery-positive rather than negative because I happened to have more connections to that than to battery-negative. In EAGLE there's a way to flood a board with copper areas, but I didn't figure out how to do that so I just made the positive wires all on the "front-side" layer in red.

Step 5: Select a Spring for the Vibration Sensor.

I had seen a spring-around-a-wire kind of vibration sensor in a car alarm once so I thought I'd show one off. I took apart the car alarm I had and realized two things: they were using a piezoelectric crystal to detect vibration, and it was broken which explained why the car alarm didn't work anymore.

I played with that for a bit. Basically it was a stiff piece of metal with a weight on the end. If the car was bumped or knocked, it would vibrate and the piezoelectric crystal would convert that vibration to a voltage. I played with it a little and found it would resonate around 80Hz or so which is roughly the same pitch as knocking on the side of a car. Neat.

Anyway, I was looking for a spring that would offer little resistance to being bent. To demonstrate the force, I used an business card with a couple springs I had in my collection. One was too stiff and the index card would bend, but the other was very fine and would easily yield to the force of the business card.

Step 6: Build the Main Circuit Board.

So here's where I get into that Manhattan-style board construction. I picked up some scrap copper-clad board from a local electronics surplus place (they were apparently trimmings from larger sheets). I liked that they were very thin and light meaning they'd be easy to cut. I snipped out a small square about big enough to hold the components. I figured I could cut it further if necessary. Nonetheless, I drilled a couple 3/16" holes so I could mount it with #10-32 machine screws.

Then I made some contact points. I don't own a metal punch but I do have a nibbling tool so I used that. I cut out little square contacts from another piece of copper-clad board.

The first thing I wired up was the vibration switch. I drilled a hole that was just as big as the solid copper wire. It was a tight fit and I had to tap it into place with a small hammer. At least I knew it was solidly in place. I soldered it to the board. Then I took the spring set it over the wire and marked a few dots where the spring touched along its radius. I selected four snippings of copper board to go around the wire and glued them in place, copper-side up. Then I set the spring in place and soldered one point on. I wanted to make sure everything was going well so I got out the meter and confirmed that the spring and center wire were isolated and that they could make electrical contact.

For the 555 timer I decided I'd use a socket. I never did Manhattan-style board construction before and I didn't know how much heat I'd be applying to pins (it turns out to be not much more than through-hole soldering). I had a piece of copper breadboard, reused from a former project, and I cut out an 8-pin piece. I bent the socket pins outward and flat then soldered them onto the breadboard, surface-mount style. I glued the breadboard to the main board. I set it up so pin 1 was toward the edge of the board because there were far fewer connections to make on that side.

I started with resistor R7 that goes from pins 8 to 7 on the 555. I bent the leads and cut them so they were approximately spaced correctly and soldered them on. I then added a pad a short distance from pin 6, gluing it in place. I did a similar bend with resistor R5 and soldered it to the IC pad to the new pad I just made.

I continued doing this until I had added all the components. I stopped briefly to test the capacitor-timer/light-sensor circuit and it worked fine.

Step 7: Build Bracket to Mount Circuit and Battery Holder.

As most people know, a 9V battery fits quite well inside a 35mm photographic film canister. I decided to use that as the weather-resistant battery holder. I fit things roughly in place around the back of the reflector and built a metal bracket by drilling some holes in a piece of thin steel. One was in the center and large enough to allow the reflector mounting screw to pass through (1/4"). I drilled two more 3/16" holes on either side, spaced fairly evenly. I just wanted a few points I could mount things.

I drilled a 3/16" hole in the side of the film canister toward the bottom. I used a #10-32 screw, nut, and washer to mount it. I cut a small hole with a hobby knife to feed the wires from the battery snap and set it in place.

Step 8: Add LED's to the Reflector.

In the reflector I selected, there is a white plastic backing behind the red-colored reflector lens. There is a gap between the two pieces so I drilled 3 holes for LED's which don't extend into the red plastic.

Then I did some experiments, wiring up an LED with clip leads and a resistor to supply around 20mA of current. What I found was the reflector material worked in reverse too, so most of the light from the LED was reflected back onto the white background. I didn't like this so I drilled further into the red plastic to remove the reflector pyramids and allow the LED light to get through. This worked great.

Then I went to wire them up. I determined that the flat on the LED shell indicated the wire on the LED that is the cathode or negative terminal. I carefully placed all the LED's in the 3 holes so the flat was on the same side then wired them in series. Between two of the LED's I needed a jumper so I decided to slip in the 100-ohm R4 current-limiting resistor instead. I tested the circuit but found it wouldn't light up. It turned out that one of the LED's had the flat on the anode, so one LED was installed backward. Once I corrected that, all 3 LED's lit up nice and bright.

I soldered on red and black wires to indicate positive and negative, respectively. I added some glue to seal the electronics from the weather and let it sit.

Step 9: Make the Main Circuit Board Weather-resistant.

I had been putting off making the main circuit board weather-resistant. I figured I could just put the vibration sensor in some kind of tube and cover the whole thing in sealant. I'd rather have something that you could open, though. I was looking around the house and found that the board fit perfectly inside a sauce cup from a takeout restaurant. Voila!

I set the board in and marked a hole then cut it out with a hobby knife. Then I cut a slot so I could insert the power wire and the LED wire. It seems to work perfectly.

Step 10: Put It All Together.

With the glue for the bracket and the sealant for the LED wiring on the reflector dry, I set to putting it all together. I soldered the power leads and LED wires to the main circuit board then mounted everything where it was supposed to go.

Step 11: Test How Well It Works and Debug the Problems.

We rode out to dinner to try the light out. In the daytime it stayed off and it started working at dusk. However, there were two problems: the vibration sensor was not nearly sensitive enough, and the light didn't blink all the time -- in fact, barely at all.

The first problem was an easy fix: add some weight to the top of the spring. I soldered on a small segment of copper wire and that made it so sensitive that you could barely hold it and walk down stairs without it detecting enough vibration to turn on.

The second problem was much more difficult. I debugged the circuit with my oscilloscope and determined there were a couple minor wiring problems. This could have been much easier if I had tested it once I wired up the 555 part of the circuit. I fixed everything I could but it just wouldn't function correctly.

I finally gave up. I think the 555 can't handle an input voltage that decreases fairly rapidly (about 0.1 volts per second, so the 9 volt initial input would drop to zero after 90 seconds or so.) This may be because the internal reference voltage it uses to detect when to toggle may stay higher than it should and therefore the capacitor will never charge to a high enough voltage to cause its internal flip-flop to trigger and drive the output low.

To get around the problem, I removed the 555 and ran a jumper from the V+ input at pin 8 to the output at pin 3. Now the light stays on steady and slowly decreases in brightness until it finally extinguishes after a few minutes.

Step 12: Compare the Outcome to the Original Specification.

So here's how I did compared to my original specification:

"The light shall not affect the 'stock' look of the bike." Check. It looks like a stock reflector unless you take a peek around the seat.

"The light shall operate only when it's dark enough to be effective." Check. It turns on only after dusk but not in the daytime.

"The light shall operate automatically when the bike is in use and for around 30-60 seconds afterward." Check. It stays bright for about 30 seconds afterward, dim for 90 seconds or so, then slowly fades to black over the course of several minutes.

"The light shall blink to enhance visibility at night." Nope. I just couldn't get this to work. In the end, though, it looks more "stock" to have it not blink, somewhat like an old incandescent battery-powered tail light.

"The battery on the light shall last 'indefinitely' when not in use." Check. I measured the current draw after the lights had been off for over a day and it came out to 1.1 microamps. Given a 540 milliamp-hour battery, that's 480,000 hours or about 54 years.

"The light shall efficiently utilize the battery's power when in use." Check. Although I didn't do a thorough test of conditions while riding, I did several measurements. When the vibration switch is activated, the circuit draws 21 mA. Once it disconnects, the circuit draws 14 mA and begins dropping -- to 11 mA after 30 seconds, and 3.7 mA after 90 seconds. Assuming it stays around 14 mA, the 540 mAH battery will provide light for about 38 hours -- or 38 hours of continuous riding.

Further, I did a test to see how the current decreases over time. If I understand it correctly, it will continue to approach the minimum of around 1.1 microamps. I measured the current after the last pulse of the vibration switch up to around 15 minutes when it was down to 200 microamps. I'll assume it takes 3 hours to drop to 1.1 microamps. If I approximate that between each time measurement that the current drops linearly, I can estimate the total energy consumed to be the average current between two points times the time between those points. Doing that, I determined that the total energy consumed the last time the vibration sensor fires is about 0.7 millamp-hours, so for a 540 mAH battery, that's about 770 times.

"The electronics of the light shall be reasonably weatherproof -- at least enough that road spray will not affect operation." Check. The film canister protects the battery and the sauce container protects the main circuit.

All told I'm quite satisfied. My girlfriend is impressed and happy about it as well.