Tilt Buzzer

Tilt Buzzer

In this project, we connect a Grove Accelerometer and a Buzzer to the Raspberry Pi to determine if the Accelerometer is tilted or not. You might use this project to detect and record motion, or to control a robot.  We use a Grove switch to turn the entire circuit on and off.

This project is a simple example to demonstrate how to use multiple Grove Sensors with GrovePi and Raspberry Pi in your Projects. Most of the parts used in this project are available in the GrovePi Starter Kit but you’ll have to get the accelerometer separately.

Tilt Buzzer Connections

Tilt Buzzer Connections

Hardware Required

  1. Raspberry Pi
  2. GrovePi
  3. Grove Accelerometer
  4. Grove Buzzer
  5. Grove Switch
  6. Grove Connection wires

Tilt Buzzer Parts

Hardware Setup: Connecting the Raspberry Pi accelerometer

Connect the Buzzer to port D2, the switch to port D4 and the Accelerometer to any of the I2C ports.

Now power on the Raspberry Pi.

Software: Running the Program

Run the tilt buzzer program in GrovePi/Projects/tilt_buzzer folder:

sudo python tilt_buzzer.py

If you turn the switch on and  tilt the accelerometer in the X direction, the buzzer will start making a sound.

tilt_buzz_desktop

Source Code

The source code for the example can be found here.

Questions?

Have a question or a problem?  Post it on the forums and we’ll help you out.

 

{"cart_token":"","hash":"","cart_data":""}