Skip to content

Commit dd05bf5

Browse files
committed
Drum_machine example added
1 parent 8c33072 commit dd05bf5

File tree

12 files changed

+104
-0
lines changed

12 files changed

+104
-0
lines changed

examples/Hover_drum.py

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# ===========================================================================
2+
# This is an example for Hover.
3+
#
4+
# Hover is a development kit that lets you control your Arduino projects in a whole new way.
5+
# Wave goodbye to physical buttons. Hover detects hand movements in the air for touch-less interaction.
6+
# It also features five touch-sensitive regions for even more options.
7+
# Hover uses I2C and 2 digital pins. It is compatible with Arduino, Raspberry pi and more.
8+
#
9+
# Hover can be purchased from here: http://www.justhover.com
10+
#
11+
# Written by Emran Mahbub and Jonathan Li for Gearseven Studios.
12+
# BSD license, all text above must be included in any redistribution
13+
# ===========================================================================
14+
#
15+
# HOOKUP GUIDE (For Raspberry Pi)
16+
#
17+
# =============================
18+
# | 1 2 3 4 5 6 7 |
19+
# | HOVER |
20+
# | |
21+
# | +++++++++++++++++++++++++++ |
22+
# | + + |
23+
# | + + |
24+
# | * + |
25+
# | * + |
26+
# | * + |
27+
# |_+++++++++++++++++++++++++++_|
28+
#
29+
# PIN 1 - HOST_V+ ---- 3V3 pin
30+
# PIN 2 - RESET ---- Any Digital Pin. This example uses GPIO 24 (BCM Mode).
31+
# PIN 3 - SCL ---- SCL pin
32+
# PIN 4 - SDA ---- SDA pin
33+
# PIN 5 - GND ---- Ground Pin
34+
# PIN 6 - 3V3 ---- 3V3 pin
35+
# PIN 7 - TS ---- Any Digital Pin. This example uses GPIO 23 (BCM Mode).
36+
#
37+
# HISTORY
38+
# v1.0 - Initial Release
39+
#
40+
# INSTALLATION
41+
# Place the Hover_library.py file in the same folder as the Hover_example.py file.
42+
# Then run Hover_example.py by typing: sudo python Hover_example.py
43+
#
44+
# SUPPORT
45+
# For questions and comments, email us at support@gearseven.com
46+
47+
48+
import pygame
49+
import time
50+
from Hover_library import Hover
51+
52+
hover = Hover(address=0x42, ts=23, reset=24)
53+
54+
pygame.mixer.init()
55+
56+
kick = pygame.mixer.Sound('samples/kick.wav')
57+
clap = pygame.mixer.Sound('samples/clap.wav')
58+
cymbal = pygame.mixer.Sound('samples/cymbal.wav')
59+
snare = pygame.mixer.Sound('samples/snare.wav')
60+
champion = pygame.mixer.Sound('samples/champion.wav')
61+
closed = pygame.mixer.Sound('samples/closed.wav')
62+
ahems = pygame.mixer.Sound('samples/ahem.wav')
63+
doit = pygame.mixer.Sound('samples/doit.wav')
64+
force = pygame.mixer.Sound('samples/force.wav')
65+
66+
try:
67+
while True:
68+
69+
# Check if hover is ready to send gesture or touch events
70+
if (hover.getStatus() == 0):
71+
# Read i2c data and print the type of gesture or touch event
72+
message = hover.getEvent()
73+
type(message)
74+
if (message == "01000010"):
75+
kick.play() #west
76+
elif (message == "01010000"):
77+
snare.play() #center
78+
elif (message == "01001000"):
79+
closed.play() #east
80+
elif (message == "01000001"):
81+
cymbal.play() #south
82+
elif (message == "01000100"):
83+
clap.play() #north
84+
elif (message == "00100010"):
85+
champion.play() #swipe right
86+
elif (message == "00100100"):
87+
ahems.play() #swipe left
88+
elif (message == "00110000"):
89+
force.play() #swipe down
90+
elif (message == "00101000"):
91+
doit.play()
92+
93+
# Release the ts pin until Hover is ready to send the next event
94+
hover.setRelease()
95+
time.sleep(0.0008) #sleep for 1ms
96+
97+
except KeyboardInterrupt:
98+
print "Exiting..."
99+
hover.end()
100+
101+
except:
102+
print "Something has gone wrong..."
103+
hover.end()

examples/readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Make sure to place these files in the same folder as Hover_library.py

examples/samples/ahems.wav

114 KB
Binary file not shown.

examples/samples/champion.wav

72.1 KB
Binary file not shown.

examples/samples/clap.wav

25.2 KB
Binary file not shown.

examples/samples/closed.wav

15.3 KB
Binary file not shown.

examples/samples/cymbal.wav

139 KB
Binary file not shown.

examples/samples/doit.wav

612 KB
Binary file not shown.

examples/samples/force.wav

450 KB
Binary file not shown.

examples/samples/kick.wav

47.3 KB
Binary file not shown.

examples/samples/open.wav

47 KB
Binary file not shown.

examples/samples/snare.wav

35.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)