-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstrumentProgram.ino
More file actions
46 lines (40 loc) · 842 Bytes
/
InstrumentProgram.ino
File metadata and controls
46 lines (40 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
void setup() {
// put your setup code here, to run once:
pinMode(2, INPUT);
pinMode(3, INPUT);
pinMode(4, INPUT);
pinMode(5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(2)) {
makeNoise(261);
}
if (digitalRead(3)) {
makeNoise(294);
}
if (digitalRead(4)) {
makeNoise(329);
}
if (digitalRead(5)) {
makeNoise(349);
}
if (digitalRead(6)) {
makeNoise(392);
}
if (digitalRead(7)) {
makeNoise(440);
}
if (digitalRead(8)) {
makeNoise(494);
}
}
void makeNoise(int frequency) {
float randomNoise = random(-analogRead(A0)/128, analogRead(A0)/128);
float pitchChange = analogRead(A1)/240;
tone(13, frequency + randomNoise + pitchChange, 10);
}