Inspired by the BeetBox made by Scott, we decided to combine Hover with a Raspberry Pi to make our very own drum machine. Customize each tap and gesture for different sound effects or even voice clips.
Connect Hover to Raspberry Pi
Here is the simplified version on how to wire up your Beam to the Raspberry Pi
- HOST_V+: Connect the HOST_V+ pin to the 3V3 pin on Raspberry Pi.
- RESET and TS: These pins are used by the library to configure Hover. These can be connected to any GPIO pins of the Raspberry. Default library uses GPIO 24 for RESET and GPIO 23 for TS.
- SCL and SDA: The I2C pins are used to read data from Hover. Connect SCL/SDA on Hover directly to the SCL0/SDA0 of the Raspberry Pi.
- 3V3 and GND: The 3.3V power supply and ground pins are used to power Hover. Connect these to the 3.3V and GND pins on Raspberry Pi.
Get some Speakers
Plug in your speakers to the Raspberry Pi
Run the Example Sketch
Open up LX Terminal and run the following two commands:
sudo modprobe snd_bcm2835 sudo amixer -c 0 cset numid=3 1
This enables sounds on the raspberry pi and sets the audio output to the AUX port. Move the Hover_drum.py and the samples folder into the same location as the Hover_library.py.
Now you're ready to run the file using this command: sudo python Hover_drum.py
Wait for Hover to Initialize and then rock on.
Understanding the Code
The key component added is the pygame code. Once you have imported pygame, you'll need to initialize the pygame mixer. After that, you can load in sounds and play them. Here is a snippet of the code.
import pygame pygame.mixer.init() kick = pygame.mixer.Sound('samples/kick.wav') kick.play()
You're all set
Hopefully at this point, your project is working as expecting. If not, try going back to the Hover Basics guide. If all else fails, you can always contact us at email@example.com