1
\$\begingroup\$

I am working on a mini flashlight project. I would like to avoid holes in the enclosure to ensure waterproof-ness so using a standard slide switch is not an option for me.

I want to use a version of this (a vibration sensor) that will latch in the "on" position (perhaps with the aid of a magnet or mechanical structure inside the sensor) when shaken and will turn off when the user shakes it again. I have done quite a bit of research and can't find anything like it. I might be missing something obvious that makes it impossible/expensive/unreliable. Thank you for your help.

EDIT: A comment to this question mentions a microcontroller. Are there any pre-made ones for my purpose? Surely it is a commonly required function.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ You could use a flip-flop, triggered by the sensor you mentioned, and a proper debounce. Alternatively, you could do the same with the sensor and a cheap microcontroller. Expect some current draw while switched off. \$\endgroup\$
    – Paul
    Commented Oct 16, 2023 at 15:23
  • \$\begingroup\$ A reed switch (inside the sealed enclosure) is reliable. Activated by a magnet outside that can be rotated into position adjacent? Much like a bicycle odometer sensor mounted on a wheel (fixed reed switch, rotating magnet) \$\endgroup\$
    – glen_geek
    Commented Oct 16, 2023 at 15:55
  • \$\begingroup\$ If you're looking for that particular type of sensor, search for SW-18030P \$\endgroup\$
    – MiNiMe
    Commented Oct 16, 2023 at 16:10
  • \$\begingroup\$ there are common and simple tilt and shock sensors. you could also use a accelerometer. An external magnet that can slide on a rail could hit a hall sensor or reed switch. My friend hacked one together in the 90s that used a latching push button/switch under the battery spring so that slamming the end down toggled the light when the batteries mashed into it. \$\endgroup\$
    – dandavis
    Commented Oct 16, 2023 at 19:02

3 Answers 3

1
\$\begingroup\$

There is MEMS sensors, it will be a bit more complicated circuit. What you have found is the analog variant of a MEMS and simpler to interface. Another variant is to use a piezo electric button.

\$\endgroup\$
1
\$\begingroup\$

The standard solution is to have a magnetic reed switch inside the non-magnetic enclosure actuated by a sliding magnet that is outside.

enter image description here

\$\endgroup\$
0
\$\begingroup\$

This was my approach for a very similar project - a thingamabob which illuminates when lightly shaken, but turns off after a couple of minutes if left undisturbed.

SW1 is a little capsule with a conductive ball inside. When said ball closes the circuit, for a brief period current flows into the base of Q1 via C1. This allows Q1 to discharge the timing capacitor C2, pulling the gate of P-MOSFET Q2 low and turning the two LEDs on.
If it is left undisturbed, R4 slowly charges C2 which eventually (about 2 minutes later) turns the LEDs off. In the off-state the circuit does draw about 1 μA via R2 if SW1 happens to stay closed, but this would still take over 20 years to discharge the two 240 mAh CR2032 button cells

One complication with this design is that you can't count on SW1 remaining open even when the device is at rest, as the ball may settle in different positions in different orientations of the device. C1 is there to ensure that even when SW1 stays closed, C1 eventually charges up and blocks further current flow to the base of Q1, allowing C2 to charge and the light to turn off.

Note that as-is this circuit is not good for a high current load. This is because Q2 will overheat while C2 slowly charges up. A high current version needs to add hysteresis to provide a sharp turn-off to Q2.

\$\endgroup\$
1
  • \$\begingroup\$ Good approach for (almost) the same problem. Note that the sensor that OP provided would actually work better in your circuit, as the spring mount ensures it is always in the Open state when not moving. \$\endgroup\$
    – Paul
    Commented Oct 20, 2023 at 12:06

Not the answer you're looking for? Browse other questions tagged or ask your own question.