Merge branch 'master' of github.com:NeilNjae/miniband
[miniband.git] / README.md
1 # Code Club - Mini Band Project
2 Updated project for Code Club, using Arduino and Raspberry Pi
3
4 <img src="http://farm9.staticflickr.com/8338/8256708023_4a941566e9.jpg" width="500" height="375" alt="photo (2)">
5
6 Make your own mini band!
7 You and your friends can form your own finger-sized band and rock out using Raspberry Pi and Arduino.
8 Learn how to build circuits with sensors and outputs and write a simple programme to control your instruments.
9
10 ## You will make:
11
12 * A guitar
13 * A set of drums
14 * A pair of maracas
15
16 ## You will need:
17
18 * 1 x Raspberry Pi (plus monitor and power supply)
19 * USB hub
20 * 2 x Arduino Uno boards (with USB cables)
21 * 1 x strip potentiometer
22 * 2 x tilt sensors
23 * 4 x piezo buzzers (the type in greetings cards, easy to get from Maplin)
24 * 10K resistors
25 * Bread boards (1 per instrument)
26 * Card
27 * Sugru (or some other modelling material)
28 * Electrical tape
29 * Plastic drinking straw
30 * Pencil
31 * Coloured pens (optional)
32
33
34 ## Software requirements:
35
36 * Scratch
37 * IDE developer environment for Arduino
38 * Py Serial library
39
40
41 ## Useful links:
42
43 * [Pictures](http://bit.ly/codeclubminiband)
44 * [Ardunio code](https://github.com/KatJoyWhite/miniband/tree/master/arduino)
45
46
47
48 ## Pull-down Resistors
49
50 You’ll find your analogue inputs receive signal when you don’t expect them to.
51 This is because there’s electricty floating around in the system, or something like that.
52
53 To fix this, you need to wire each input to ground, through a 10KΩ resistor.
54
55 A better explanation can be found [here](http://arduino.cc/en/Tutorial/DigitalPins).
56
57
58
59 ## Drum Kit
60
61 <img src="http://farm9.staticflickr.com/8074/8257699966_7585ca06e7.jpg" width="375" height="500" alt="Code Club Miniband"><
62
63 ### 1. Make your drums
64
65 Take your 4 piezo buzzers and attach a ring of Sugru (or other modelling material) as shown in the picture.
66 This will increase the flexibility and resonance of the sensors. Let the sugru set.
67
68 <img src="http://farm9.staticflickr.com/8353/8256628815_6c3872d3ac.jpg" width="500" height="375" alt="Code Club Miniband">
69
70
71 ### 2. Connect the circuit
72
73 Piezo buzzers generate a small charges when you tap them, so they don’t need a power source.
74 Connect one lead from your buzzer to one of your analogue inputs, and connect the other lead to ground.
75 Repeat for each of your drums. It is easiest to use a bread board for making your circuit.
76 Look at the picture for an example.
77
78 <img src="http://farm9.staticflickr.com/8081/8256628955_f65a76b6fb.jpg" width="500" height="375" alt="Code Club Miniband">
79
80 ### 3. Program the Arduino
81
82 Find the appropriate code from the respository and upload to your Ardunio board.
83
84
85 ### 4. Set up in Scratch
86
87 Find four different drum sounds (or whatever sounds you'd like your drums to make!). Upload the sounds to Scratch.
88
89
90 ## Guitar
91
92 <img src="http://farm9.staticflickr.com/8070/8257698984_8471e4cf57.jpg" width="500" height="375" alt="Code Club Miniband">
93
94 ### 1. Make your guitar
95
96 Grab your strip potentiomater, a piece of thin card, and a pencil.
97 Lightly draw round your potentiometer on the card and then use this as a guide to draw out your guitar shape.
98 (The potentiomater will be the fret board of your guitar).
99 Cut out and colour in the guitar and stick down the potentiomater.
100 Tape a pencil or stick to the back of the guitar to make it stiffen the fret board.
101
102 ### 2. Connect the circuit
103
104 The potentiomater strip adjusts resistance, so you will need to feed it some electricity.
105 Run +5V into one of the strip’s outer pins, and ground into the other outer pin.
106 It doesn’t matter which way around you connect these, but it will affect which the direction
107 the fretboard runs (high and the top, low at the bottom or vice-versa).
108
109 Signal will come from the centre pin, so connect that to one of your analogue inputs and you should be good to go.
110
111 <img src="http://farm9.staticflickr.com/8363/8257699194_a2645e0e06.jpg" width="500" height="375" alt="Code Club Miniband">
112
113 ### 3. Program the Arduino
114
115 Find the appropriate code from the respository and upload to your Ardunio board.
116
117
118 ### 4. Set up in Scratch
119
120 Find five different guitar sounds and upload to Scratch.
121
122
123 ## Maracas
124
125 <img src="http://farm9.staticflickr.com/8346/8257698652_4a99ee24b4.jpg" width="500" height="375" alt="Code Club Miniband">
126
127 ### 1. Make your maracas
128
129 Cut 2 short lengths of drinking straw for your maraca handles.
130 Using Sugru (or other modelling material), make 2 maraca heads by rolling it up into balls.
131 Push the maraca heads onto the straws and mold into a maraca shape.
132 Connect lengths of wire to the connectors of the 2 tilt sensors and then push each sensor into a straw until it presses into the Sugru.
133 Leave the Sugru to set.
134
135 <img src="http://farm9.staticflickr.com/8222/8256627511_118192e52f.jpg" width="500" height="375" alt="Code Club Miniband">
136
137 ### 2. Connect the circuit
138
139 Connect the +5V port on the Arduino board to one of the pins on the tilt switch (it doesn't matter which way round).
140 Connect the other pin to an empty digital input on the board.
141
142 <img src="http://farm9.staticflickr.com/8348/8257698572_4157db0b20.jpg" width="500" height="375" alt="Code Club Miniband">
143
144 ### 3. Program the Arduino
145
146 Find the appropriate code from the respository and upload to your Ardunio board.
147
148
149 ### 4. Set up in Scratch
150
151 Find a maraca / shaker sound and upload to Scratch.
152
153
154 ## Connecting to the Raspberry Pi
155
156 Set up your Raspberry Pi with a power supply and monitor.
157 Connect all your Ardunio boards (it's easiest to have one per instrument!) to the Raspberry Pi using USB.
158 You will probably need a USB hub.
159
160
161 ## Python glueware
162
163 Download the music-maker-hander.py file from the repository. Run it with
164 python music-maker-handler.py
165 This program sets up a listener for each instrument. When it detects that an instrument has been played, it sends a couple of signals to Scratch.
166
167 The first signal appears in Scratch as a sensor value and is the volume (for drums), pitch (for the guitar), or ignored (for the maracas).
168
169 The second signal is a broadcast message that makes Scratch play the sound in the instrument.
170
171 One problem we had was with how the operating sytem mapped the various Arduinos to devices. It seemed to be pretty arbitrary. In the end, we tracked the device names by running
172 tail -f /var/log/syslog
173 in a separate terminal and watching what the devices were called when we plugged them in. We could then edit the various DEVICE parameters in to top of the Python script to fit. You could probably be cleverer by using some udev rules to fix the device names, but we didn't think of that (and didn't have enough time either).
174
175 ## Scratch front end
176
177 The Scratch file, music-maker, makes the sounds. It responds to the signals from the Python handler above by playing the appropriate sounds. It also does some visual feedback for the insturments.
178
179 Scratch on the Raspberry Pi is very slow, especially when it comes to updating the screen. Very often, Scratch would hang mid-way through a jamming session, only to start playing all the sounds after a short while. During the demos, people suggested that we minimise the Scratch window to reduce its workload.