Introduction
Do you want to switch lights by just shaking your hand? However, you may don't want to use a complicated and costly triple axis accelerometer. This digital shake sensor is sure to meet your needs.
The digital shake sensor is to detect hand shaking which only sensitive to unidirectional hand movements. The spring-type vibration switch is used to output a low-level pulse when the user shakes once in the specified direction and the on-board indicator flashes at the same time. Thanks to the unidirectional sensitivity of the vibration switch and the corresponding filter circuit, it has strong anti-shock interference capability to prevent false triggering. Simple and easy, switch controls are all in just a single shake.
Features
- Unidirection sensitive, strong anti-shock interference, preventing false triggering
- Compatible with 3.3V/5V controller
- Compact design, easy to install
Applications
- Shaking Light Stick
- Shake Switch
Specifications
- Input Voltage (VCC): 3.3V~5.0V
- Switch Life Span: Over 200,000 times
- Interface: Gravity 3P Digital
- Dimension: 30.0mm*22.0mm
Board Overview

Label | Name | Description |
---|---|---|
+ | VCC | Power VCC(3.3~5.5V) |
- | GND | Power GND |
D | Digital | Digital output (high-level when stationary, low-level pulse when shaken) |
PWR | Power | Power indicator (red), turned on when power up |
ON | ON | Shake triggered indicator (blue) |
How to Shake the Sensor

The vibration switch used by the sensor is unidirectional sensitivity. As shown in the above figure, the user can hold the module just like the logo on the module, and shake it in the direction of the arrow indicated on-board (from +Y to Y-). This will generate an effective low-level interrupt pulse on the “D” pin and a bright flash on the indicator ON. Shakes or vibrations in other directions like the X or Z do not produce an effective interrupt pulse.
Arduino Tutorial
This tutorial presents a basic usage of the module with Arduino UNO.
Requirements
- Hardware
- DFRduino UNO R3 (or similar) x 1
- DFRobot Gravity: Digital Shake Sensor x 1
- Gravity 3P digital wire (or Dupont wires) x 1
- Software
Connection Diagram

Example Codes
#define LED_PIN 13
#define DIGITAL_INPUT_PIN 3 //Connect the sensor to digital Pin 3 which is Interrupts 1.
unsigned char stateFlag = 0;
unsigned long timepoint = 0;
void setup()
{
pinMode(LED_PIN, OUTPUT);
// Set to input mode with internal pull-up.
// Otherwise, it will fail to generate intterupts under 3.3V power supply.
pinMode(DIGITAL_INPUT_PIN, INPUT_PULLUP);
attachInterrupt(1, toggleLED, FALLING); // Trigger LED toggle function when the falling edge is detected
timepoint = millis();
}
void loop()
{
// toggle onboard LED
if (stateFlag != 0){
digitalWrite(LED_PIN, HIGH);
}
else {
digitalWrite(LED_PIN, LOW);
}
}
//Interrupt serivce routinue
void toggleLED()
{
// The hardware has done some filter.
// To further improve stability, here add a 50ms for debouncing.
// This will not block the main function.
if (millis() - timepoint > 50U){
timepoint = millis();
stateFlag = (stateFlag + 1) % 2;
}
}
Results
- In the direction indicated by the arrow on-board, every time the module is shaken, the ON indicator on the sensor will flash once. The indicator L on the Arduino UNO will be toggled once.
Micro:bit Tutorial
This tutorial presents a basic usage of the module with Raspberry Pi.
Requirements
- Hardware
- Micro:bit x 1
- Micro:mate x 1
- DFRobot Gravity: Digital Shake Sensor x 1
- Gravity 3P digital wire (or Dupont wires) x 1
- Software
Connection Diagram

Example Codes
.png)
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.
More Documents
Get SEN0289 Gravity: Digital Shake Sensor from DFRobot Store or DFRobot Distributor.