Grove - Collision Sensor

From Wiki
Jump to: navigation, search


Grove - Collision Sensor can detect whether any collision movement or vibration happens. It will output a low pulse signal when vibration is detected. To make the output signal more reliable and neat, we added a necessary exterior circuit to reduce the noise impact. So, normal shaking will not cause any output. The sensor has a high sensitivity, then you can use it to apply to your project, such as automatic wake-up and power-down for battery management. Its working voltage is 5v which make it compatible with standard Arduino/Seeeduino 5V system.

400px-Grove – Collision Sensor photo.jpg


Voltage: 3.3/5V


With Arduino Based on the output signal will change when a collision happens, we design this demo: each time the sensor detects collision, the LED will light up. Here the LED is as a managed device, and you can refer to the demo to control your device, such as bicycle light. The procedure is as follows: 1. Connect the collision sensor to the Digital port 2 of Grove - Basic Shield using a Grove cable and connect an LED to Pin 13. 2. Plug the Grove - Basic Shield into Arduino. 3. Connect Arduino/Seeeduino to PC by using a USB cable. 4. Copy and paste code below to a new Arduino sketch. And upload it to your Arduino.

/****************************************************************************/ // Function: Monitor if there is any collision // Hardware: Grove - Collision Sensor // Arduino IDE: Arduino-1.0 // by // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either // version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // // You should have received a copy of the GNU Lesser General Public // License along with this library; if not, write to the Free Software // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // /*******************************************************************************/

  1. define LED 13 //the onboard LED of Arduino or Seeeduino
  2. define COLLISION_SENSOR 2//collision sensor is connected with D2 of Arduino

void setup() { pins_init(); }

void loop() {




else turnOffLED();


void pins_init() {


} boolean isTriggered() {

 	return true;//the collision sensor triggers
   return false;

} void turnOnLED() { digitalWrite(LED,HIGH);//the LED is on } void turnOffLED() { digitalWrite(LED,LOW);//the LED is off } 5. Now you can check the status of LED. The LED should light up every time you drum fingers on the table. You can adjust the sensor sensitivity by changing the function delay(50) in code.

 	return true;//the collision sensor triggers
   return false;

With Raspberry Pi 1.You should have got a raspberry pi and a grovepi or grovepi+. 2.You should have completed configuring the development enviroment, otherwise follow here. 3.Connection Plug the sensor to grovepi socket D2 by using a grove cable. 4.Navigate to the demos' directory:

  cd yourpath/GrovePi/Software/Python/

To see the code

  nano   # "Ctrl+x" to exit #

import time import grovepi

  1. Connect the Grove Collision Sensor to digital port D2

collision_sensor = 2


while True:

       print grovepi.digitalRead(collision_sensor)
   except IOError:
       print "Error"

5.Run the demo.

  sudo python