hands-on Arduino introduction making a sequencer to send 3 channels of pulse signals to a drum chip (Arduino based dsp-D8)
designed for 2 workshops at Sonar Hong Kong, 17 March 2018
3. Arduino workshop 2018
Before we start… check the connection between your
Arduino board and your laptop:
● plugin your Arduino board USB cable into your laptop
● open Arduino IDE software (www.arduino.cc)
● open the Blink sketch from File>Examples>Basic
● pick the correct port from Tools>Serial Port
● pick the correct board type from Tools>Board “Uno”
● hit ‘upload’ to test the connection
● look for ‘Done uploading’ and check if the onboard LED
is blinking
4. Arduino workshop 2018
Arduino: what is it?
Arduino is an open-source
electronics prototyping platform
based on flexible, easy-to-use
hardware and software
It is intended for artists, designers,
hobbyists and anyone interested in
creating interactive objects or
environments
• sensors
• sound
• light
• wifi
• ...
7. Arduino workshop 2018
Arduino vs Raspberry Pi
➔ looks similar
➔ similar price
➔ micro-controller vs
mini-computer
➔ Arduino: IO
➔ Pi: OS
Other popular platforms:
ESP8266, Particle Photon, micro:bit
8. Arduino workshop 2018
Arduino boards
➔ many official boards
➔ different sizes
➔ different connections
➔ use same code
➔ mostly compatible
➔ extra functions via shields
10. Arduino workshop 2018
Arduino-style boards
➔ many copies
➔ many improvements
➔ extra functions included
(Wifi, GPS, motor, Ethernet,...)
➔ use same code
➔ mostly compatible
➔ cheaper!
11. Arduino workshop 2018
Arduino software: IDE
➔ Integrated Development Environment
➔ Write sketch -> upload to board
➔ Useful examples
➔ ‘Libraries’ to make our life easier
Always make sure to pick the correct BOARD
➔ Connect using USB cable, pick correct PORT
➔ Upload sketch
➔ Check output of Serial Monitor
➔ Save your sketches..
12. Arduino workshop 2018
Arduino software: Web Editor
Same functionality with:
➔ Browser based editor (needs login)
➔ Accessible from any computer
➔ Storage in the cloud
➔ Need to sign up for username
➔ Need to install the Arduino Create plugin for upload
13. Arduino workshop 2018
Basic electronics
➔ DC direct current vs alternating current AC
➔ voltage: volts 5V (usb), 3V3, 9V
➔ current: milli ampere 40 mA = 0.04 A
➔ power: watts 1-2 W (USB limit)
➔ resistors: reduce voltage
➔ diodes: one-way + light
➔ capacitors: small battery
➔ schematics
14. Arduino workshop 2018
Basic electronics
DIGITAL: on/off
1/0
true/false
high/low
0V/5V
ANALOG: variable 0->5V
Ohm’s law: U = I * R
Kirchoff’s laws:
19. Arduino workshop 2018
Arduino projects for today
➔ Blink: the ‘hello world’ of Arduino pinMode
digitalWrite
delay
➔ Read push button digitalRead
➔ Read potentiometer analogRead
Build the step sequencer
Connect to drum PCB
20. Arduino workshop 2018
Arduino: ‘blink’ sketch
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
*/
// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
initialisation
setup { }
loop { }
change these numbers and see what happens
‘upload’ after each change!
File>Open> “Desktop/workshop/blink1/blink1.ino”
21. Arduino workshop 2018
Arduino: blink
Blink: the ‘hello world’ of Arduino
220 ohm
LEDs short straight leg goes
into the blue line (GND)
22. Arduino workshop 2018
resistor colour code
220 ohm = 220 Ω
red red black black (brown)
10k ohm = 10,000 Ω
brown black black red
(brown)
23. Arduino workshop 2018
connect the drum PCB
8 inputs - power - speaker
power:
PWR+ goes to 5V (red line on breadboard)
PWR- goes to GND (blue line on breadboard)
speaker:
connect SPK+
and SPK-
BD = bass drum
SD = snare drum
CH = closed hi-hat
OH = open hi-hat
RS = rim shot
CL = clap
RD = ride
CR = crash
28. Arduino workshop 2018
Arduino: potentiometer
[replace loop with]
void loop() {
digitalWrite(13, HIGH);
delay(10);
digitalWrite(13, LOW);
delay(analogRead(A0));
}
[analogRead returns 0->1023]put the pot legs in
columns 8,10,12
29. Arduino workshop 2018
Serial Monitor and Plotter
[add this line to setup]
Serial.begin(9600);
[modify loop to]
digitalWrite(13, HIGH);
delay(100);
digitalWrite(13, LOW);
Serial.println(analogRead(A0));
34. Arduino workshop 2018
connect clock to drum PCB
add a long wire from the breadboard
(dot of segment display, column 5) to
the drum PCB, any input e.g. CH
CH
39. Arduino workshop 2018
play/step mode
modify loop:
showStep();
if (playMode()) {
sendPulses();
delay(analogRead(A0));
} else {
editStep();
}
increaseStep();
add a wire from D2 to
GND (blue line)
40. Arduino workshop 2018
edit step mode
with the D2 wire connected, move to next step with button 4
the LEDs show
which drum is
active for that step
use the 3 buttons
to toggle on/off
41. Arduino workshop 2018
hack it :-)
● change the 3+1 output wires to different drum sounds
● use a wire connected to GND to trigger other drum
sounds while the sequence is playing
● change the code to 6 steps
● replace the drum samples in the drum chip with your own
samples
● build a box for this sequencer
● ...
42. Arduino workshop 2018
drum chip
Arduino chip (Atmega328p)
Open Source code “dsp-D8” from
https://janostman.wordpress.com/2016/01/03/the-dsp-d8-drumchip-source-code/
(minor modifications)
43. Arduino workshop 2018
Arduino: suppliers
ONLINE
➔ Official Arduino shop: http://arduino.cc/
great documentation, projects, forum
➔ Seeedstudio: http://www.seeedstudio.com/depot/
➔ Telesky: https://telesky.world.tmall.com/
➔ Adafruit: http://www.adafruit.com/ great documentation
IN HONG KONG - Apliu St
➔ WECL http://www.weclonline.com/wecl_eng/index.html
45. Arduino workshop 2018
Dimsum Labs
the hackerspace of HK www.dimsumlabs.com/
community of technology enthusiasts
space for creativity in Sheung Wan
Tuesday evening HackJam
www.facebook.com/groups/hackjamhk/