I wanted to make an auto-off bike light because I just keep forgetting to switch it off and the batteries are constantly flat. And I hate dynamos.

I was looking into accelerometers, but couldn’t find one that would enter sleep mode and give me interrupts with zero configuration. This implies using microcontroller and it gets boring pretty fast. So I decided to choose the low-tech way. All I needed was a switch that would close when disturbed mechanically. After digging in various junk bins I found a spring and came up with this solution:

switch circuit The schematics are simple:


The resistor keeps the mosfet off. When the switch is closed briefly, capacitor instantly charges up above the mosfet’s gate threshold voltage, the mosfet turns on the LED. Then the capacitor discharges slowly through the resistor until its voltage drops below the gate threshold voltage, causing the mosfet to turn off. So if my spring switch closes rapidly while I ride (say, at least once in a minute), the light stays on. If I stop for more than a minute, the light goes off. I chose a 10 megaohm resistor and a 22uF capacitor, in theory this should give about 30 seconds until the threshold voltage is reached.

This is the switch with the circuit soldered:


A copper clad board, a knife and smd components…