Skip to content
If this is your first visit, please click here to learn about shipping and delivery.
If this is your first visit, please touch here to learn about shipping and delivery.
Flat spring-contact vibration switches for breadboard experiments

Turn a Vibration Switch into a Reliable Bump Detector: Capture, Grouping and Mounting

A vibration switch can be a useful input for a moved-object indicator, interactive prop or simple bump logger. Its apparent simplicity hides a software question: should ten contact closures mean ten bumps, or one bump that made the internal spring oscillate?

The breadboard-friendly flat vibration switch in PMD Way's vibration sensor collection provides a concrete example. The listing describes a normally open spring contact with low sensitivity and a directional response to side impacts. Treat it as an event input whose behaviour must be measured in its mounting position.

Know what a contact closure tells you

When the moving contact touches the fixed contact, the electrical circuit closes. The resulting pulse says that the mechanism moved far enough to make contact. It does not directly report acceleration, vibration amplitude, impact energy or frequency.

The spring can make several contacts after one disturbance. A slow tilt might produce a different pattern from a quick tap, and an impact along an insensitive direction might produce little response. Counting closures per second is therefore a measure of contact activity, not automatically a calibrated vibration quantity.

Define the intended event in ordinary language before coding. “The box was disturbed after arming” is a realistic first goal. “The box experienced an impact above a specified acceleration” requires a suitable measuring sensor and a validated method.

Use a defined logic input

For a low-voltage prototype, use a documented switch-input circuit that keeps the input at a known level when the contact is open. A pull-up to the controller's permitted logic rail with the switch returning to ground is a common arrangement; it produces a low input when the switch closes.

Arduino's digital input pull-up tutorial explains this basic technique. Check the actual board's input specifications and pull-up behaviour. Do not connect the switch to an unrelated higher-voltage rail.

The public product description does not provide a complete contact voltage and current rating. Obtain those limits for the supplied part before finalising a design, and use it as a small signal contact rather than switching a motor, lamp or other load directly.

Keep the first test leads short and secure. Check the idle state without touching the assembly, then gently disturb the mounting surface. If the input changes when the cable is handled but the switch remains still, investigate wiring and interference before changing event thresholds.

Capture the raw activity before filtering it

A short contact closure can fall entirely between two slow polling reads. Logging the input once every second may show nothing even though the switch is operating. Start by observing the waveform or recording edge timestamps with an acquisition method fast enough for the actual pulses.

An interrupt-capable input can help capture brief events. Arduino's attachInterrupt documentation covers board-dependent pin choices and trigger modes. Capture one selected edge per closure, and keep the interrupt routine short. Perform serial printing, display updates and event interpretation elsewhere.

If shared counters or timestamps are updated in an interrupt, use the appropriate declarations and safe access for the processor. A volatile variable is not automatically an atomic multi-byte transaction. Check the board's implementation when transferring a captured record to the main application.

Store enough raw information to inspect what happened: timestamp, edge count and any acquisition overflow. Losing records during a busy display update should be visible in diagnostics rather than mistaken for a quiet interval.

Do not apply a pushbutton filter blindly

A conventional button remains closed while it is pressed. Arduino's Debounce example waits for a stable state before accepting a change. That is useful for its intended button behaviour, but a vibration switch may never remain closed for such a long interval.

If every legitimate pulse is brief, requiring a sustained closure can reject the entire event. Separate two tasks: capturing genuine contact activity and deciding how to group that activity into one application event. Select each rule from recorded traces.

Group a burst using a quiet interval

A simple grouping rule starts a burst at the first accepted closure. Each later closure updates the last-activity time. Once the input has been quiet for a chosen interval, the application closes the burst and records one event.

For an illustrative test, suppose closures occur at 0, 7, 19 and 42 ms after a tap. A 100 ms quiet interval would close that burst 142 ms after the first closure. A separate closure at 400 ms would start another burst. These numbers explain the method; they are not specifications or universal settings for the stock switch.

The quiet interval determines what your count means. A longer interval merges closely spaced disturbances, while a shorter one can split a ringing response. Compare several candidate values against labelled test actions rather than choosing whichever produces the most attractive count.

Make the mounting part of the sensor

Attach the switch in a repeatable orientation and mark its sensitive direction. A flexible breadboard, stiff enclosure and loose cable can each transmit a different disturbance to the contact mechanism. Finalise the mechanical arrangement before selecting the final event rule.

Use ordinary, gentle test actions representative of the project. For a desk prop, compare a nearby table tap, picking up the object, replacing it and touching a control button. Do not use damaging impacts merely to find a maximum response.

Keep a test table with action, direction, raw closure pattern and grouped result. Include events that should be ignored as well as events that should be detected. This reveals whether mounting changes can improve discrimination before more software is added.

Define arming, re-arming and fault behaviour

A moved-object indicator may need time for the user to place the object after pressing an arm button. Use an explicit arming state, then begin detection after the assembly has settled according to the chosen rule. Show when the detector is actually armed.

After a detection, decide whether the indicator latches until reset or automatically re-arms after quiet. Avoid automatically resetting while the object is still being handled if the user expects a record of the first disturbance.

Test startup, long periods at rest and a contact that remains closed. A stuck-low input should not be counted as an endless sequence of new bumps. Keep that fault distinct from repeated transitions.

Save the mounting orientation, capture method and grouping parameters with the project. A well-tested vibration switch can provide a useful qualitative event input, provided the displayed result describes what the switch actually observed.

Previous article Battery Power for Arduino Projects: Voltage Range, Runtime and Regulator Heat