Merge branch 'master' of ssh://git.xpub.nl:2501/XPUB/special-issue-x

master
Damlanur 5 years ago
commit b7f6e35620

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 548 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

@ -0,0 +1,26 @@
G04 MADE WITH FRITZING*
G04 WWW.FRITZING.ORG*
G04 DOUBLE SIDED*
G04 HOLES PLATED*
G04 CONTOUR ON CENTER OF CONTOUR VECTOR*
%ASAXBY*%
%FSLAX23Y23*%
%MOIN*%
%OFA0B0*%
%SFA1.0B1.0*%
%ADD10R,1.574800X4.330720*%
%ADD11C,0.008000*%
%ADD10C,0.008*%
%LNCONTOUR*%
G90*
G70*
G54D10*
G54D11*
X4Y4327D02*
X1571Y4327D01*
X1571Y4D01*
X4Y4D01*
X4Y4327D01*
D02*
G04 End of contour*
M02*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,142 @@
; NON-PLATED HOLES START AT T1
; THROUGH (PLATED) HOLES START AT T100
M48
INCH
T1C0.118110
T100C0.035000
T101C0.059842
T102C0.041333
T103C0.031497
T104C0.027559
T105C0.041361
T106C0.040000
T107C0.036000
T108C0.088356
%
T1
X003813Y003215
X003235Y041435
X003194Y035784
X011198Y003139
X003161Y030136
T100
X000984Y018796
X005310Y038880
X005571Y007479
X000984Y015796
X005153Y027087
X005794Y005506
X001310Y038880
X005227Y033065
X010721Y007459
X007968Y035647
X001794Y005506
X007968Y032647
X001227Y033065
X013234Y025361
X013234Y032065
X014457Y006093
X008600Y005338
X014457Y003093
X007927Y038050
X001153Y027087
X007897Y029940
X015234Y025361
X015234Y032065
X007897Y026940
X008571Y007479
X007927Y041050
T101
X004525Y035787
X004566Y041438
X008647Y003136
X013135Y003136
X001257Y035787
X001224Y030139
X001298Y041438
X005144Y003218
X004492Y030139
X005745Y035787
X005712Y030139
X001876Y003218
X009868Y003136
X005786Y041438
X006364Y003218
T102
X011116Y038572
X010116Y038572
X011162Y027241
X010162Y027241
X011230Y033093
X010230Y033093
T103
X006405Y040081
X006491Y006284
X006405Y039097
X006067Y028893
X006067Y027909
X006157Y033817
X007475Y006284
X006157Y034801
T104
X012007Y000775
X011007Y000775
T105
X012162Y027241
X012230Y033093
X012116Y038572
T106
X000955Y011805
X001955Y012805
X000972Y023598
X000955Y009805
X000955Y013805
X000972Y021038
X000955Y010805
X002752Y023598
X001955Y011805
X002752Y021038
X000955Y012805
X001955Y009805
X001955Y013805
X001955Y010805
T107
X010670Y014823
X004670Y010823
X010670Y011823
X004670Y018823
X004670Y022823
X010670Y019823
X004670Y015823
X010670Y023823
X010670Y016823
X004670Y012823
X010670Y009823
X010670Y020823
X010670Y013823
X010670Y010823
X004670Y017823
X004670Y021823
X010670Y018823
X004670Y014823
X010670Y022823
X010670Y015823
X004670Y011823
X010670Y012823
X004670Y019823
X004670Y023823
X004670Y016823
X004670Y009823
X004670Y020823
X010670Y017823
X004670Y013823
X010670Y021823
T108
X013103Y030194
X009220Y030194
X009288Y036046
X013058Y041525
X009174Y041525
X013171Y036046
T00
M30

@ -0,0 +1,175 @@
G04 MADE WITH FRITZING*
G04 WWW.FRITZING.ORG*
G04 DOUBLE SIDED*
G04 HOLES PLATED*
G04 CONTOUR ON CENTER OF CONTOUR VECTOR*
%ASAXBY*%
%FSLAX23Y23*%
%MOIN*%
%OFA0B0*%
%SFA1.0B1.0*%
%ADD10C,0.084000*%
%ADD11C,0.085000*%
%ADD12C,0.075000*%
%ADD13C,0.117087*%
%ADD14C,0.128110*%
%ADD15C,0.084667*%
%ADD16C,0.084695*%
%ADD17C,0.134033*%
%ADD18C,0.080000*%
%ADD19C,0.072992*%
%ADD20R,0.079972X0.080000*%
%ADD21R,0.072992X0.072992*%
%LNMASK0*%
G90*
G70*
G54D10*
X97Y2104D03*
X97Y2360D03*
X275Y2104D03*
X275Y2360D03*
G54D11*
X579Y551D03*
X179Y551D03*
X515Y2709D03*
X115Y2709D03*
X523Y3307D03*
X123Y3307D03*
X531Y3888D03*
X131Y3888D03*
X1523Y3207D03*
X1323Y3207D03*
X1523Y2536D03*
X1323Y2536D03*
X98Y1880D03*
X98Y1580D03*
X1072Y746D03*
X860Y534D03*
X1446Y609D03*
X1446Y309D03*
G54D12*
X1101Y78D03*
X1201Y78D03*
G54D13*
X636Y322D03*
X514Y322D03*
X188Y322D03*
G54D14*
X381Y322D03*
G54D13*
X571Y3014D03*
X449Y3014D03*
X122Y3014D03*
G54D14*
X316Y3014D03*
G54D13*
X575Y3579D03*
X453Y3579D03*
X126Y3579D03*
G54D14*
X319Y3578D03*
G54D13*
X579Y4144D03*
X457Y4144D03*
X130Y4144D03*
G54D14*
X324Y4144D03*
G54D13*
X865Y314D03*
X987Y314D03*
X1314Y314D03*
G54D14*
X1120Y314D03*
G54D15*
X1016Y2724D03*
X1116Y2724D03*
G54D16*
X1216Y2724D03*
G54D17*
X922Y3019D03*
X1310Y3019D03*
G54D15*
X1023Y3309D03*
X1123Y3309D03*
G54D16*
X1223Y3309D03*
G54D17*
X929Y3605D03*
X1317Y3605D03*
G54D15*
X1012Y3857D03*
X1112Y3857D03*
G54D16*
X1212Y3857D03*
G54D17*
X917Y4153D03*
X1306Y4153D03*
G54D18*
X1067Y982D03*
X1067Y1082D03*
X1067Y1182D03*
X1067Y1282D03*
X1067Y1382D03*
X1067Y1482D03*
X1067Y1582D03*
X1067Y1682D03*
X1067Y1782D03*
X1067Y1882D03*
X1067Y1982D03*
X1067Y2082D03*
X1067Y2182D03*
X1067Y2282D03*
X1067Y2382D03*
X467Y982D03*
X467Y1082D03*
X467Y1182D03*
X467Y1282D03*
X467Y1382D03*
X467Y1482D03*
X467Y1582D03*
X467Y1682D03*
X467Y1782D03*
X467Y1882D03*
X467Y1982D03*
X467Y2082D03*
X467Y2182D03*
X467Y2282D03*
X467Y2382D03*
G54D11*
X857Y748D03*
X557Y748D03*
X790Y2694D03*
X790Y2994D03*
X797Y3265D03*
X797Y3565D03*
X793Y3805D03*
X793Y4105D03*
G54D19*
X649Y628D03*
X748Y628D03*
X607Y2791D03*
X607Y2889D03*
X616Y3382D03*
X616Y3480D03*
X641Y3910D03*
X641Y4008D03*
G54D10*
X96Y1381D03*
X196Y1381D03*
X96Y1281D03*
X196Y1281D03*
X96Y1181D03*
X196Y1181D03*
X96Y1081D03*
X196Y1081D03*
X96Y981D03*
X196Y981D03*
G54D20*
X1067Y982D03*
G54D21*
X649Y628D03*
X607Y2791D03*
X616Y3382D03*
X641Y3910D03*
G04 End of Mask0*
M02*

@ -0,0 +1,191 @@
G04 MADE WITH FRITZING*
G04 WWW.FRITZING.ORG*
G04 DOUBLE SIDED*
G04 HOLES PLATED*
G04 CONTOUR ON CENTER OF CONTOUR VECTOR*
%ASAXBY*%
%FSLAX23Y23*%
%MOIN*%
%OFA0B0*%
%SFA1.0B1.0*%
%ADD10C,0.084000*%
%ADD11C,0.085000*%
%ADD12C,0.075000*%
%ADD13C,0.117087*%
%ADD14C,0.128110*%
%ADD15C,0.084667*%
%ADD16C,0.084695*%
%ADD17C,0.134033*%
%ADD18C,0.080000*%
%ADD19C,0.072992*%
%ADD20R,0.079972X0.080000*%
%ADD21R,0.072992X0.072992*%
%LNMASK1*%
G90*
G70*
G54D10*
X97Y2104D03*
X97Y2360D03*
X275Y2104D03*
X275Y2360D03*
X97Y2104D03*
X97Y2360D03*
X275Y2104D03*
X275Y2360D03*
G54D11*
X579Y551D03*
X179Y551D03*
X515Y2709D03*
X115Y2709D03*
X523Y3307D03*
X123Y3307D03*
X531Y3888D03*
X131Y3888D03*
X1523Y3207D03*
X1323Y3207D03*
X1523Y2536D03*
X1323Y2536D03*
X98Y1880D03*
X98Y1580D03*
X1072Y746D03*
X860Y534D03*
X1446Y609D03*
X1446Y309D03*
G54D12*
X1101Y78D03*
X1201Y78D03*
X1101Y78D03*
X1201Y78D03*
G54D13*
X636Y322D03*
X514Y322D03*
X188Y322D03*
G54D14*
X381Y322D03*
G54D13*
X571Y3014D03*
X449Y3014D03*
X122Y3014D03*
G54D14*
X316Y3014D03*
G54D13*
X575Y3579D03*
X453Y3579D03*
X126Y3579D03*
G54D14*
X319Y3578D03*
G54D13*
X579Y4144D03*
X457Y4144D03*
X130Y4144D03*
G54D14*
X324Y4144D03*
G54D13*
X865Y314D03*
X987Y314D03*
X1314Y314D03*
G54D14*
X1120Y314D03*
G54D15*
X1016Y2724D03*
X1116Y2724D03*
G54D16*
X1216Y2724D03*
G54D17*
X922Y3019D03*
X1310Y3019D03*
G54D15*
X1023Y3309D03*
X1123Y3309D03*
G54D16*
X1223Y3309D03*
G54D17*
X929Y3605D03*
X1317Y3605D03*
G54D15*
X1012Y3857D03*
X1112Y3857D03*
G54D16*
X1212Y3857D03*
G54D17*
X917Y4153D03*
X1306Y4153D03*
G54D18*
X1067Y982D03*
X1067Y1082D03*
X1067Y1182D03*
X1067Y1282D03*
X1067Y1382D03*
X1067Y1482D03*
X1067Y1582D03*
X1067Y1682D03*
X1067Y1782D03*
X1067Y1882D03*
X1067Y1982D03*
X1067Y2082D03*
X1067Y2182D03*
X1067Y2282D03*
X1067Y2382D03*
X467Y982D03*
X467Y1082D03*
X467Y1182D03*
X467Y1282D03*
X467Y1382D03*
X467Y1482D03*
X467Y1582D03*
X467Y1682D03*
X467Y1782D03*
X467Y1882D03*
X467Y1982D03*
X467Y2082D03*
X467Y2182D03*
X467Y2282D03*
X467Y2382D03*
G54D11*
X857Y748D03*
X557Y748D03*
X790Y2694D03*
X790Y2994D03*
X797Y3265D03*
X797Y3565D03*
X793Y3805D03*
X793Y4105D03*
G54D19*
X649Y628D03*
X748Y628D03*
X607Y2791D03*
X607Y2889D03*
X616Y3382D03*
X616Y3480D03*
X641Y3910D03*
X641Y4008D03*
G54D10*
X96Y1381D03*
X196Y1381D03*
X96Y1281D03*
X196Y1281D03*
X96Y1181D03*
X196Y1181D03*
X96Y1081D03*
X196Y1081D03*
X96Y981D03*
X196Y981D03*
X96Y1381D03*
X196Y1381D03*
X96Y1281D03*
X196Y1281D03*
X96Y1181D03*
X196Y1181D03*
X96Y1081D03*
X196Y1081D03*
X96Y981D03*
X196Y981D03*
G54D20*
X1067Y982D03*
G54D21*
X649Y628D03*
X607Y2791D03*
X616Y3382D03*
X641Y3910D03*
G04 End of Mask1*
M02*

@ -0,0 +1,77 @@
*Pick And Place List
*Company=
*Author=
*eMail=
*
*Project=graan2
*Date=17:48:55
*CreatedBy=Fritzing 0.9.3b.04.19.5c895d327c44a3114e5fcc9d8260daf0cbb52806
*
*
*Coordinates in mm, always center of component
*Origin 0/0=Lower left corner of PCB
*Rotation in degree (0-360, math. pos.)
*
*No;Value;Package;X;Y;Rotation;Side;Name
1;10k;THT;24.5384;-16.2528;135;Bottom;R8
2;;;16.2814;-59.454;0;Bottom;Copper Fill16
3;;;21.9202;-72.027;0;Bottom;Copper Fill14
4;;;30.2006;-86.2002;0;Bottom;Copper Fill7
5;;;9.0932;-98.062;0;Bottom;Copper Fill5
6;;;33.528;-59.3524;0;Bottom;Copper Fill17
7;;;31.6738;-104.133;0;Bottom;Copper Fill3
8;;;29.6672;-13.5816;0;Bottom;Copper Fill25
9;;;33.4518;-26.4086;0;Bottom;Copper Fill22
10;;;29.2608;-5.2504;0;Bottom;Copper Fill31
11;;;2.7432;-11.4226;0;Bottom;Copper Fill26
12;;;24.5618;-80.1804;0;Bottom;Copper Fill11
13;;;8.79926;-90.9032;-90;Bottom;J2 - A1
14;1k;THT;8.40768;-98.7576;180;Bottom;R3
15;;;8.5344;-5.225;0;Bottom;Copper Fill28
16;;;21.7932;-65.042;0;Bottom;Copper Fill15
17;;;1.4986;-101.593;0;Bottom;Copper Fill4
18;;;21.844;-3.9042;0;Bottom;Copper Fill30
19;;2x5-ra;4.75904;-29.987;0;Bottom;JP
20;;;17.0434;-30.7774;0;Bottom;Copper Fill21
21;10k;THT;2.50162;-43.934;90;Bottom;R6
22;;;21.9964;-86.5812;0;Bottom;Copper Fill9
23;;THT;28.3421;-74.0176;-90;Bottom;P3 = A0
24;;THT;28.2264;-102.798;-90;Bottom;P1 = A2
25;;;9.1948;-16.4264;0;Bottom;Copper Fill23
26;;;14.097;-103.421;0;Bottom;Copper Fill2
27;0;THT;36.1566;-64.4186;180;Bottom;R2
28;;THT;20.241;-86.7345;-90;Bottom;LDR2
29;1k;THT;8.01088;-68.8011;180;Bottom;R5
30;;;19.5072;-52.6722;0;Bottom;Copper Fill18
31;;;1.4224;-87.1654;0;Bottom;Copper Fill8
32;;THT;17.9623;-18.9969;180;Bottom;LDR4
33;150;THT;36.7222;-11.6662;90;Bottom;R9
34;;;29.591;-70.6808;0;Bottom;Copper Fill12
35;;;8.9408;-52.1642;0;Bottom;Copper Fill20
36;;;8.9916;-83.7364;0;Bottom;Copper Fill10
37;;cap-pth-small2;29.2292;-1.96985;0;Bottom;C1 105
38;;THT;20.1363;-100.459;-90;Bottom;LDR1
39;;3 mm [THT];16.2691;-99.958;0;Bottom;LED1
40;1k;THT;8.19827;-83.9855;180;Bottom;R4
41;;;8.71657;-76.5565;-90;Bottom;J4 - A0
42;;;24.511;-21.1762;0;Bottom;Copper Fill24
43;;;33.02;-46.1698;0;Bottom;Copper Fill19
44;;;10.3724;-8.17837;-90;Bottom;J3TRIG - A3
45;;;19.4832;-42.7411;180;Bottom;NANO
46;;;19.9898;-55.009;0;Bottom;Copper Fill1
47;;THT;28.5151;-88.8831;-90;Bottom;P2 = A1
48;0;THT;36.1566;-81.4461;180;Bottom;R1
49;;3 mm [THT];15.6409;-86.5473;0;Bottom;LED2
50;;3 mm [THT];17.1389;-15.9631;90;Bottom;LED4
51;;;8.90397;-105.256;-90;Bottom;J1 - A2
52;;;27.7595;-7.96332;90;Bottom;J4 OUT
53;;;1.3716;-72.4842;0;Bottom;Copper Fill13
54;;;27.686;-94.379;0;Bottom;Copper Fill6
55;1k;THT;9.63676;-13.9874;180;Bottom;R7
56;;THT;20.0587;-72.2377;-90;Bottom;LDR3
57;;;35.6108;-4.0058;0;Bottom;Copper Fill29
58;;;19.2159;-61.1188;0;Bottom;TXT1
59;;;19.3802;-11.3464;0;Bottom;Copper Fill27
60;;;33.6131;-35.6043;-90;Bottom;TXT1
61;;3 mm [THT];15.4106;-71.5404;0;Bottom;LED3
62;;tactile-pth;4.73004;-56.6899;-90;Bottom;S1

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -0,0 +1,56 @@
int A;
int B;
int C;
bool BA;
bool BB;
bool BC;
void setup() {
Serial.begin(9600);
}
void loop() {
A = analogRead (A1);
Serial.print ("A=");
Serial.println (A);
B = analogRead (A2);
Serial.print ("B=");
Serial.println (B);
C = analogRead (A3);
Serial.print ("C=");
Serial.println (C);
if (A>100 && !BA) {
tone(9, 200);
BA = true;
}
else if (A<100 && BA){
noTone(9);
BA = false;
}
if (B>100 && !BB) {
tone(9, 400);
BB = true;
}
else if (B<100 && BB){
noTone(9);
BB = false;
}
if (C>100 && !BC) {
tone(9, 600);
BC = true;
}
else if (C<100 && BC){
noTone(9);
BC = false;
}
}

@ -0,0 +1,194 @@
#include <MozziGuts.h>
#include <Oscil.h>
#include <tables/saw256_int8.h>
#include <Adafruit_ADS1015.h>
#include <Wire.h>
//#include <mozzi_fixmath.h>
//#include <utility/twi_nonblock.h>
#define CONTROL_RATE 128 // powers of 2 please
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_1(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_2(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_3(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_4(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_5(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_6(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_7(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_8(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_9(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_10(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_11(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_12(SAW256_DATA);
//multiplex adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
int count= 0;
int TH;
int16_t adc0a, adc1a, adc2a, adc3a, adc0b, adc1b, adc2b, adc3b, adc0c, adc1c, adc2c, adc3c, adc0d, adc1d, adc2d, adc3d;
boolean note1 = false;
boolean note2 = false;
boolean note3 = false;
boolean codeswitch = false;
void setup(){
//set the gain for multiplexed ins
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
//start the multiplexing
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
startMozzi(CONTROL_RATE);
//set tone frequency and phase
tone_1.setFreq(165);
tone_1.setPhase(0);
tone_2.setFreq(196);
tone_2.setPhase(30);
tone_3.setFreq(220);
tone_3.setPhase(60);
tone_4.setFreq(262);
tone_4.setPhase(90);
tone_5.setFreq(330);
tone_5.setPhase(120);
tone_6.setFreq(392);
tone_6.setPhase(150);
tone_7.setFreq(440);
tone_7.setPhase(180);
tone_8.setFreq(523);
tone_8.setPhase(210);
tone_9.setFreq(659);
tone_9.setPhase(240);
tone_10.setFreq(784);
tone_10.setPhase(270);
tone_11.setFreq(880);
tone_11.setPhase(300);
tone_12.setFreq(1047);
tone_12.setPhase(330);
//calibrate (set treshold)
TH = adsb.readADC_SingleEnded(3);
}
void updateControl(){
//log number of notes playing
if (adc0a < TH) {
count++;
}
if (adc1a < TH) {
count++;
}
if (adc2a < TH) {
count++;
}
if (adc3a < TH) {
count++;
}
if (adc0b < TH) {
count++;
}
if (adc1b < TH) {
count++;
}
if (adc2b < TH) {
count++;
}
if (adc3b < TH) {
count++;
}
if (adc0c < TH) {
count++;
}
if (adc1c < TH) {
count++;
}
if (adc2c < TH) {
count++;
}
if (adc3c < TH) {
count++;
}
}
int updateAudio(){
int result = 0;
//Play notes and mix down (according to notes playing
if (adc0a < TH) {
result += tone_1.next() * (1/count);
}
if (adc1a < TH) {
result += tone_2.next() * (1/count);
}
if (adc2a < TH) {
result += tone_3.next() * (1/count);
}
if (adc3a < TH) {
result += tone_4.next() * (1/count);
}
if (adc0b < TH) {
result += tone_5.next() * (1/count);
}
if (adc1b < TH) {
result += tone_6.next() * (1/count);
}
if (adc2b < TH) {
result += tone_7.next() * (1/count);
}
if (adc3b < TH) {
result += tone_8.next() * (1/count);
}
if (adc0c < TH) {
result += tone_9.next() * (1/count);
}
if (adc1c < TH) {
result += tone_10.next() * (1/count);
}
if (adc2c < TH) {
result += tone_11.next() * (1/count);
}
if (adc3c < TH) {
result += tone_12.next() * (1/count);
}
return result;
}
void loop(){
//Messure LDR multiplex inputs
adc0a = adsa.readADC_SingleEnded(0);
adc1a = adsa.readADC_SingleEnded(1);
adc2a = adsa.readADC_SingleEnded(2);
adc3a = adsa.readADC_SingleEnded(3);
adc0b = adsb.readADC_SingleEnded(0);
adc1b = adsb.readADC_SingleEnded(1);
adc2b = adsb.readADC_SingleEnded(2);
adc3b = adsb.readADC_SingleEnded(3);
adc0c = adsc.readADC_SingleEnded(0);
adc1c = adsc.readADC_SingleEnded(1);
adc2c = adsc.readADC_SingleEnded(2);
adc3c = adsc.readADC_SingleEnded(3);
adc0d = adsd.readADC_SingleEnded(0);
adc1d = adsd.readADC_SingleEnded(1);
adc2d = adsd.readADC_SingleEnded(2);
adc3d = adsd.readADC_SingleEnded(3);
audioHook();
}

@ -0,0 +1,680 @@
#include <MusicWithoutDelay.h>
//#include <synth.h>
//#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=600,o=3:c+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=600,o=3:d+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=600,o=3:e+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=600,o=3:g+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=600,o=3:a+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=600,o=4:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=600,o=4:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=600,o=4:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=600,o=4:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=600,o=4:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=600,o=5:c+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=600,o=5:d+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=600,o=5:e+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=600,o=5:g+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=600,o=5:a+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=600,o=6:c+"; //plays c7
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
int ZER;
int ONE;
int TWO;
int THR;
int FOU;
int FIV;
int SIX;
int SEV;
int EIG;
int NIN;
int TEN;
int ELE;
int TWE;
int THT;
int FOT;
int FIT;
void setup() {
Serial.begin(115200);
pinMode(20, INPUT);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
calib();
Insta.begin(CHA, TRIANGLE, ENVELOPE0, 0);
Instb.begin(TRIANGLE, ENVELOPE0, 0);
Instc.begin(TRIANGLE, ENVELOPE0, 0);
Instd.begin(TRIANGLE, ENVELOPE0, 0);
Inste.begin(TRIANGLE, ENVELOPE0, 0);
Instf.begin(TRIANGLE, ENVELOPE0, 0);
Instg.begin(TRIANGLE, ENVELOPE0, 0);
Insth.begin(TRIANGLE, ENVELOPE0, 0);
Insti.begin(TRIANGLE, ENVELOPE0, 0);
Instj.begin(TRIANGLE, ENVELOPE0, 0);
Instk.begin(TRIANGLE, ENVELOPE0, 0);
Instl.begin(TRIANGLE, ENVELOPE0, 0);
Instm.begin(TRIANGLE, ENVELOPE0, 0);
Instn.begin(TRIANGLE, ENVELOPE0, 0);
Insto.begin(TRIANGLE, ENVELOPE0, 0);
Instp.begin(TRIANGLE, ENVELOPE0, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void calib() {
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
}
void loop() {
bool curcv = digitalRead(20);
// Serial.println (curcv);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (CV != curcv) {
CV = curcv;
// CV changes
// Serial.print("cv");
// Serial.println(CV);
if (CV) {
// entering Audio
Serial.println("entering Audio");
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
digitalWrite(15, LOW);
digitalWrite(16, LOW);
} else {
//entering CV
Serial.println("entering CV");
ZER = false;
ONE = false;
TWO = false;
THR = false;
FOU = false;
FIV = false;
SIX = false;
SEV = false;
EIG = false;
NIN = false;
TEN = false;
ELE = false;
TWE = false;
THT = false;
FOT = false;
FIT = false;
}
}
if (!CV) {
control();
} else {
audio();
}
//if (digitalRead(17) == LOW) {
//calib();
//}
}
void control() {
if (VA0 > TH0) {
digitalWrite(0, HIGH);
}
else if (VA0 < TH0) {
digitalWrite(0, LOW);
}
if (VA1 > TH1) {
digitalWrite(1, HIGH);
}
else if (VA1 < TH1) {
digitalWrite(1, LOW);
}
if (VA2 > TH2) {
digitalWrite(2, HIGH);
}
else if (VA2 < TH2) {
digitalWrite(2, LOW);
}
if (VA3 > TH3) {
digitalWrite(4, HIGH);
}
else if (VA3 < TH3) {
digitalWrite(4, LOW);
}
if (VA4 > TH4) {
digitalWrite(5, HIGH);
}
else if (VA4 < TH4) {
digitalWrite(5, LOW);
}
if (VA5 > TH5) {
digitalWrite(7, HIGH);
}
else if (VA5 < TH5) {
digitalWrite(7, LOW);
}
if (VA6 > TH6) {
digitalWrite(6, HIGH);
}
else if (VA6 < TH6) {
digitalWrite(6, LOW);
}
if (VA7 > TH7) {
digitalWrite(8, HIGH);
}
else if (VA7 < TH7) {
digitalWrite(8, LOW);
}
if (VA8 > TH8) {
digitalWrite(9, HIGH);
}
else if (VA8 < TH8) {
digitalWrite(9, LOW);
}
if (VA9 > TH9) {
digitalWrite(10, HIGH);
}
else if (VA9 < TH9) {
digitalWrite(10, LOW);
}
if (VA10 > TH10) {
digitalWrite(12, HIGH);
}
else if (VA10 < TH10) {
digitalWrite(12, LOW);
}
if (VA11 > TH11) {
digitalWrite(11, HIGH);
}
else if (VA11 < TH11) {
digitalWrite(11, LOW);
}
if (VA12 > TH12) {
digitalWrite(13, HIGH);
}
else if (VA12 < TH12) {
digitalWrite(13, LOW);
}
if (VA13 > TH13) {
digitalWrite(14, HIGH);
}
else if (VA13 < TH13) {
digitalWrite(14, LOW);
}
if (VA14 > TH14) {
digitalWrite(15, HIGH);
}
else if (VA14 < TH14) {
digitalWrite(15, LOW);
}
if (VA15 > TH15) {
digitalWrite(16, HIGH);
}
else if (VA15 < TH15) {
digitalWrite(16, LOW);
}
}
void audio () {
if (ZER = (VA0 > TH0)) count++;
if (ONE = (VA1 > TH1)) count++;
if (TWO = (VA2 > TH2)) count++;
if (THR = (VA3 > TH3)) count++;
if (FOU = (VA4 > TH4)) count++;
if (FIV = (VA5 > TH5)) count++;
if (SIX = (VA6 > TH6)) count++;
if (SEV = (VA7 > TH7)) count++;
if (EIG = (VA8 > TH8)) count++;
if (NIN = (VA9 > TH9)) count++;
if (TEN = (VA10 > TH10)) count++;
if (ELE = (VA11 > TH11)) count++;
if (TWE = (VA12 > TH12)) count++;
if (THT = (VA13 > TH13)) count++;
if (FOT = (VA14 > TH14)) count++;
if (FIV = (VA15 > TH15)) count++;
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
}
if (!ZER) {
Insta.pause (true);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
}
if (!ONE) {
Instb.pause (true);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
}
if (!TWO) {
Instc.pause (true);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
}
if (!THR) {
Instd.pause (true);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
}
if (!FOU) {
Inste.pause (true);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
}
if (!FIV) {
Instf.pause (true);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
}
if (!SIX) {
Instg.pause (true);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
}
if (!SEV) {
Insth.pause (true);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
}
if (!EIG) {
Insti.pause (true);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
}
if (!NIN) {
Instk.pause (true);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
}
if (!TEN) {
Instk.pause (true);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
}
if (!ELE) {
Instl.pause (true);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
}
if (!TWE) {
Instm.pause (true);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
}
if (!THT) {
Instn.pause (true);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
}
if (!FOT) {
Insto.pause (true);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
}
if (!FIT) {
Instp.pause (true);
}
Serial.print("Intruments playing = ");
Serial.println(count);
}

@ -0,0 +1,504 @@
#include <SensorToButton.h>
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
//note values
const char note1[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note5[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note6[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note7[] PROGMEM = ":d=128,b=300:f+"; //plays f5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:b+"; //plays b5
//instruments
MusicWithoutDelay myI(note1);
MusicWithoutDelay myIn(note2);
MusicWithoutDelay myIns(note3);
MusicWithoutDelay myInst(note4);
MusicWithoutDelay myInstr(note5);
MusicWithoutDelay myInstru(note6);
MusicWithoutDelay myInstrum(note7);
MusicWithoutDelay myInstrume(note8);
MusicWithoutDelay myInstrumen(note9);
MusicWithoutDelay myInstrument(note10);
int count;
//int vol;
//int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9;
bool CV;
//bool BA;
//bool BB;
//bool BC;
//bool BD;
//bool BE;
//bool BF;
//bool BG;
//bool BH;
//bool BI;
//bool BJ;
SensorToButton button0(TH0, pressUp, 50);
SensorToButton button1(TH1, pressUp, 50);
SensorToButton button2(TH2, pressUp, 50);
SensorToButton button3(TH3, pressUp, 50);
SensorToButton button4(TH4, pressUp, 50);
SensorToButton button5(TH5, pressUp, 50);
SensorToButton button6(TH6, pressUp, 50);
SensorToButton button7(TH7, pressUp, 50);
SensorToButton button8(TH8, pressUp, 50);
SensorToButton button9(TH9, pressUp, 50);
void setup() {
Serial.begin(9600);
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (analogRead(A0)+20);
TH1 = (analogRead(A1)+20);
TH2 = (analogRead(A2)+20);
TH3 = (analogRead(A3)+20);
TH4 = (analogRead(A4)+20);
TH5 = (analogRead(A5)+20);
TH6 = (analogRead(A6)+20);
TH7 = (analogRead(A7)+20);
TH8 = (analogRead(A8)+20);
TH9 = (analogRead(A9)+20);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
myI.begin(CHA, SINE, ENVELOPE0, 0);
myIn.begin(SINE, ENVELOPE0, 0);
myIns.begin(SINE, ENVELOPE0, 0);
myInst.begin(SINE, ENVELOPE0, 0);
myInstr.begin(SINE, ENVELOPE0, 0);
myInstru.begin(SINE, ENVELOPE0, 0);
myInstrum.begin(SINE, ENVELOPE0, 0);
myInstrume.begin(SINE, ENVELOPE0, 0);
myInstrumen.begin(SINE, ENVELOPE0, 0);
myInstrument.begin(SINE, ENVELOPE0, 0);
myI.pause(true);
myIn.pause(true);
myIns.pause(true);
myInst.pause(true);
myInstr.pause(true);
myInstru.pause(true);
myInstrum.pause(true);
myInstrume.pause(true);
myInstrumen.pause(true);
myInstrument.pause(true);
Serial.println("go!");
}
void loop() {
CV = digitalRead(22);
count = 0;
button0.read (A0);
button1.read (A1);
button2.read (A2);
button3.read (A3);
button4.read (A4);
button5.read (A5);
button6.read (A6);
button7.read (A7);
button8.read (A8);
button9.read (A9);
myI.update();
myIn.update();
myIns.update();
myInst.update();
myInstr.update();
myInstru.update();
myInstrum.update();
myInstrume.update();
myInstrumen.update();
myInstrument.update();
//Messure LDR inputs
// VA0 = analogRead(A0);
// VA1 = analogRead(A1);
// VA2 = analogRead(A2);
// VA3 = analogRead(A3);
//
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
// VA4 = analogRead(A4);
// VA5 = analogRead(A5);
// VA6 = analogRead(A6);
// VA7 = analogRead(A7);
//
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
// VA8 = analogRead(A8);
// VA9 = analogRead(A9);
//
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.println(" ");
if (button0.isPressed()) {
count++;
}
if (button1.isPressed()) {
count++;
}
if (button2.isPressed()) {
count++;
}
if (button3.isPressed()) {
count++;
}
if (button4.isPressed()) {
count++;
}
if (button5.isPressed()) {
count++;
}
if (button6.isPressed()) {
count++;
}
if (button7.isPressed()) {
count++;
}
if (button8.isPressed()) {
count++;
}
if (button9.isPressed()) {
count++;
}
Serial.print("Intruments playing = ");
Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (button0.isPressed()) {
//vol = 100/count + 25;
myI.play(true);
// myI.setVolume(vol);
VOL0 = constrain(map(analogRead(A0), TH0, 500, 30, 127), 30, 127);
//myI.setMod(VOL0);
myI.setVolume(VOL0);
// BA == true;
Serial.print("Tone1 active at vol:");
Serial.println(VOL0);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(23, HIGH);
}
else if(!CV) {
digitalWrite(23, LOW);
}
}
if(button0.wasReleased()){
myI.pause (true);
// BA == false;
//Kill ControlVoltage
digitalWrite(23, LOW);
}
if (button1.isPressed()) {
// vol = 100/count + 25;
myIn.play(true);
// myIn.setVolume(vol);
VOL1 = constrain(map(analogRead(A1), TH1, 500, 30, 127), 30, 127);
//myIn.setMod(VOL1);
myIn.setVolume(VOL1);
// BB == true;
Serial.print("Tone2 active at vol:");
Serial.println(VOL1);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(25, HIGH);
}
else if(!CV) {
digitalWrite(25, LOW);
}
}
if(button1.wasReleased()){
myIn.pause (true);
// BB == false;
//Kill ControlVoltage
digitalWrite(25, LOW);
}
if (button2.isPressed()) {
// vol = 100/count + 25;
myIns.play(true);
// myIns.setVolume(vol);
VOL2 = constrain(map(analogRead(A2), TH2, 500, 30, 127), 30, 127);
//myIns.setMod(VOL2);
myIns.setVolume(VOL2);
// BC == true;
Serial.print("Tone3 active at vol:");
Serial.println(VOL2);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(27, HIGH);
}
else if(!CV) {
digitalWrite(27, LOW);
}
}
if(button2.wasReleased()){
myIns.pause (true);
// BC == false;
//Kill ControlVoltage
digitalWrite(27, LOW);
}
if (button3.isPressed()) {
// vol = 100/count + 25;
myInst.play(true);
// myInst.setVolume(vol);
VOL3 = constrain(map(analogRead(A3), TH3, 500, 30, 127), 30, 127);
//myInst.setMod(VOL3);
myInst.setVolume(VOL3);
// BD == true;
Serial.print("Tone4 active at vol:");
Serial.println(VOL3);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(29, HIGH);
}
else if(!CV) {
digitalWrite(29, LOW);
}
}
if(button3.wasReleased()){
myInst.pause (true);
// BD == false;
//Kill ControlVoltage
digitalWrite(29, LOW);
}
if (button4.isPressed()) {
// vol = 100/count + 25;
myInstr.play(true);
// myInstr.setVolume(vol);
VOL4 = constrain(map(analogRead(A4), TH4, 500, 30, 127), 30, 127);
//myInstr.setMod(VOL4);
myInstr.setVolume(VOL4);
// BE == true;
Serial.print("Tone5 active at vol:");
Serial.println(VOL4);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(31, HIGH);
}
else if(!CV) {
digitalWrite(31, LOW);
}
}
if(button4.wasReleased()){
myInstr.pause (true);
// BE == false;
//Kill ControlVoltage
digitalWrite(31, LOW);
}
if (button5.isPressed()) {
// vol = 100/count + 25;
myInstru.play(true);
// myInstru.setVolume(vol);
VOL5 = constrain(map(analogRead(A5), TH5, 500, 30, 127), 30, 127);
//myInstru.setMod(VOL5);
myInstru.setVolume(VOL5);
// BF == true;
Serial.print("Tone6 active at vol:");
Serial.println(VOL5);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(33, HIGH);
}
else if(!CV) {
digitalWrite(33, LOW);
}
}
if(button5.wasReleased()){
myInstru.pause (true);
// BF == false;
//Kill ControlVoltage
digitalWrite(33, LOW);
}
if (button6.isPressed()) {
// vol = 100/count + 25;
myInstrum.play(true);
// myInstrum.setVolume(vol);
VOL6 = constrain(map(analogRead(A6), TH6, 500, 30, 127),30, 127);
//myInstrum.setMod(VOL6);
myInstrum.setVolume(VOL6);
// BG == true;
Serial.print("Tone7 active at vol:");
Serial.println(VOL6);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(35, HIGH);
}
else if(!CV) {
digitalWrite(35, LOW);
}
}
if(button6.wasReleased()){
myInstrum.pause (true);
// BG == false;
//Kill ControlVoltage
digitalWrite(35, LOW);
}
if (button7.isPressed()) {
// vol = 100/count + 25;
myInstrume.play(true);
// myInstrume.setVolume(vol);
VOL7 = constrain(map(analogRead(A7), TH7, 500, 30, 127), 30, 127);
//myInstrume.setMod(VOL7);
myInstrume.setVolume(VOL7);
// BH == true;
Serial.print("Tone8 active at vol:");
Serial.println(VOL7);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(37, HIGH);
}
else if(!CV) {
digitalWrite(37, LOW);
}
}
if(button7.wasReleased()){
myInstrume.pause (true);
// BH == false;
//Kill ControlVoltage
digitalWrite(37, LOW);
}
if (button8.isPressed()) {
// vol = 100/count + 25;
myInstrumen.play(true);
// myInstrumen.setVolume(vol);
VOL8 = constrain(map(analogRead(A8), TH8, 500, 30, 127), 30, 127);
//myInstrumen.setMod(VOL8);
myInstrumen.setVolume(VOL8);
// BI == true;
Serial.print("Tone9 active at vol:");
Serial.println(VOL8);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(39, HIGH);
}
else if(!CV) {
digitalWrite(39, LOW);
}
}
if(button8.wasReleased()){
myInstrumen.pause (true);
// BI == false;
//Kill ControlVoltage
digitalWrite(39, LOW);
}
if (button9.isPressed()) {
// vol = 100/count + 25;
myInstrument.play(true);
// myInstrument.setVolume(vol);
VOL9 = constrain(map(analogRead(A9), TH9, 500, 30, 127), 30, 127);
//myInstrument.setMod(VOL9);
myInstrument.setVolume(VOL9);
// BJ == true;
Serial.print("Tone10 active at vol:");
Serial.println(VOL9);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(41, HIGH);
}
else if(!CV) {
digitalWrite(41, LOW);
}
}
if(button9.wasReleased()){
myInstrument.pause (true);
// BJ == false;
//Kill ControlVoltage
digitalWrite(41, LOW);
}
}

@ -0,0 +1,571 @@
#include <SensorToButton.h>
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
//note values
const char note1[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note5[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note6[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note7[] PROGMEM = ":d=128,b=300:f+"; //plays f5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:b+"; //plays b5
//instruments
MusicWithoutDelay myI(note1);
MusicWithoutDelay myIn(note2);
MusicWithoutDelay myIns(note3);
MusicWithoutDelay myInst(note4);
MusicWithoutDelay myInstr(note5);
MusicWithoutDelay myInstru(note6);
MusicWithoutDelay myInstrum(note7);
MusicWithoutDelay myInstrume(note8);
MusicWithoutDelay myInstrumen(note9);
MusicWithoutDelay myInstrument(note10);
int count;
//int vol;
//int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9;
bool CV;
bool ZER;
bool ONE;
bool TWO;
bool THR;
bool FOU;
bool FIV;
bool SIX;
bool SEV;
bool EIG;
bool NIN;
SensorToButton button0(TH0, pressUp, 50);
SensorToButton button1(TH1, pressUp, 50);
SensorToButton button2(TH2, pressUp, 50);
SensorToButton button3(TH3, pressUp, 50);
SensorToButton button4(TH4, pressUp, 50);
SensorToButton button5(TH5, pressUp, 50);
SensorToButton button6(TH6, pressUp, 50);
SensorToButton button7(TH7, pressUp, 50);
SensorToButton button8(TH8, pressUp, 50);
SensorToButton button9(TH9, pressUp, 50);
void setup() {
Serial.begin(9600);
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (analogRead(A0) + 20);
TH1 = (analogRead(A1) + 20);
TH2 = (analogRead(A2) + 20);
TH3 = (analogRead(A3) + 20);
TH4 = (analogRead(A4) + 20);
TH5 = (analogRead(A5) + 20);
TH6 = (analogRead(A6) + 20);
TH7 = (analogRead(A7) + 20);
TH8 = (analogRead(A8) + 20);
TH9 = (analogRead(A9) + 20);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
myI.begin(CHA, SINE, ENVELOPE0, 0);
myIn.begin(SINE, ENVELOPE0, 0);
myIns.begin(SINE, ENVELOPE0, 0);
myInst.begin(SINE, ENVELOPE0, 0);
myInstr.begin(SINE, ENVELOPE0, 0);
myInstru.begin(SINE, ENVELOPE0, 0);
myInstrum.begin(SINE, ENVELOPE0, 0);
myInstrume.begin(SINE, ENVELOPE0, 0);
myInstrumen.begin(SINE, ENVELOPE0, 0);
myInstrument.begin(SINE, ENVELOPE0, 0);
myI.pause(true);
myIn.pause(true);
myIns.pause(true);
myInst.pause(true);
myInstr.pause(true);
myInstru.pause(true);
myInstrum.pause(true);
myInstrume.pause(true);
myInstrumen.pause(true);
myInstrument.pause(true);
Serial.println("go!");
}
void loop() {
CV = digitalRead(22);
count = 0;
button0.read (A0);
button1.read (A1);
button2.read (A2);
button3.read (A3);
button4.read (A4);
button5.read (A5);
button6.read (A6);
button7.read (A7);
button8.read (A8);
button9.read (A9);
myI.update();
myIn.update();
myIns.update();
myInst.update();
myInstr.update();
myInstru.update();
myInstrum.update();
myInstrume.update();
myInstrumen.update();
myInstrument.update();
//Messure LDR inputs
// VA0 = analogRead(A0);
// VA1 = analogRead(A1);
// VA2 = analogRead(A2);
// VA3 = analogRead(A3);
//
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
// VA4 = analogRead(A4);
// VA5 = analogRead(A5);
// VA6 = analogRead(A6);
// VA7 = analogRead(A7);
//
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
// VA8 = analogRead(A8);
// VA9 = analogRead(A9);
//
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.println(" ");
if (button0.isPressed()) {
count++;
ZER == true;
}
else {
ZER == false;
}
if (button1.isPressed()) {
count++;
ONE == true;
}
else {
ONE == false;
}
if (button2.isPressed()) {
count++;
TWO == true;
}
else {
TWO == false;
}
if (button3.isPressed()) {
count++;
THR == true;
}
else {
THR == false;
}
}
if (button4.isPressed()) {
count++;
FOU == true;
}
else {
FOU == false;
}
}
if (button5.isPressed()) {
count++;
FIV == true;
}
else {
FIV == false;
}
}
if (button6.isPressed()) {
count++;
SIX == true;
}
else {
SIX == false;
}
}
if (button7.isPressed()) {
count++;
SEV == true;
}
else {
SEV == false;
}
}
if (button8.isPressed()) {
count++;
EIG == true;
}
else {
EIG == false;
}
}
if (button9.isPressed()) {
count++;
NIN == true;
}
else {
NIN == false;
}
}
Serial.print("Intruments playing = ");
Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
//vol = 100/count + 25;
myI.play(true);
// myI.setVolume(vol);
VOL0 = constrain(map(analogRead(A0), TH0, 500, 30, 127), 30, 127);
//myI.setMod(VOL0);
myI.setVolume(VOL0);
// BA == true;
Serial.print("Tone0 active at vol:");
Serial.println(VOL0);
Serial.println(analogRead(A0));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(23, HIGH);
}
else if (!CV) {
digitalWrite(23, LOW);
}
}
if (!ZER) {
myI.pause (true);
// BA == false;
//Kill ControlVoltage
digitalWrite(23, LOW);
}
if (button1.isPressed()) {
// vol = 100/count + 25;
myIn.play(true);
// myIn.setVolume(vol);
VOL1 = constrain(map(analogRead(A1), TH1, 500, 30, 127), 30, 127);
//myIn.setMod(VOL1);
myIn.setVolume(VOL1);
// BB == true;
Serial.print("Tone1 active at vol:");
Serial.println(VOL1);
Serial.println(analogRead(A1));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(25, HIGH);
}
else if (!CV) {
digitalWrite(25, LOW);
}
}
if (button1.wasReleased()) {
myIn.pause (true);
// BB == false;
//Kill ControlVoltage
digitalWrite(25, LOW);
}
if (button2.isPressed()) {
// vol = 100/count + 25;
myIns.play(true);
// myIns.setVolume(vol);
VOL2 = constrain(map(analogRead(A2), TH2, 500, 30, 127), 30, 127);
//myIns.setMod(VOL2);
myIns.setVolume(VOL2);
// BC == true;
Serial.print("Tone2 active at vol:");
Serial.println(VOL2);
Serial.println(analogRead(A2));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(27, HIGH);
}
else if (!CV) {
digitalWrite(27, LOW);
}
}
if (button2.wasReleased()) {
myIns.pause (true);
// BC == false;
//Kill ControlVoltage
digitalWrite(27, LOW);
}
if (button3.isPressed()) {
// vol = 100/count + 25;
myInst.play(true);
// myInst.setVolume(vol);
VOL3 = constrain(map(analogRead(A3), TH3, 500, 30, 127), 30, 127);
//myInst.setMod(VOL3);
myInst.setVolume(VOL3);
// BD == true;
Serial.print("Tone3 active at vol:");
Serial.println(VOL3);
Serial.println(analogRead(A3));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(29, HIGH);
}
else if (!CV) {
digitalWrite(29, LOW);
}
}
if (button3.wasReleased()) {
myInst.pause (true);
// BD == false;
//Kill ControlVoltage
digitalWrite(29, LOW);
}
if (button4.isPressed()) {
// vol = 100/count + 25;
myInstr.play(true);
// myInstr.setVolume(vol);
VOL4 = constrain(map(analogRead(A4), TH4, 500, 30, 127), 30, 127);
//myInstr.setMod(VOL4);
myInstr.setVolume(VOL4);
// BE == true;
Serial.print("Tone4 active at vol:");
Serial.println(VOL4);
Serial.println(analogRead(A4));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(31, HIGH);
}
else if (!CV) {
digitalWrite(31, LOW);
}
}
if (button4.wasReleased()) {
myInstr.pause (true);
// BE == false;
//Kill ControlVoltage
digitalWrite(31, LOW);
}
if (button5.isPressed()) {
// vol = 100/count + 25;
myInstru.play(true);
// myInstru.setVolume(vol);
VOL5 = constrain(map(analogRead(A5), TH5, 500, 30, 127), 30, 127);
//myInstru.setMod(VOL5);
myInstru.setVolume(VOL5);
// BF == true;
Serial.print("Tone5 active at vol:");
Serial.println(VOL5);
Serial.println(analogRead(A5));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(33, HIGH);
}
else if (!CV) {
digitalWrite(33, LOW);
}
}
if (button5.wasReleased()) {
myInstru.pause (true);
// BF == false;
//Kill ControlVoltage
digitalWrite(33, LOW);
}
if (button6.isPressed()) {
// vol = 100/count + 25;
myInstrum.play(true);
// myInstrum.setVolume(vol);
VOL6 = constrain(map(analogRead(A6), TH6, 500, 30, 127), 30, 127);
//myInstrum.setMod(VOL6);
myInstrum.setVolume(VOL6);
// BG == true;
Serial.print("Tone6 active at vol:");
Serial.println(VOL6);
Serial.println(analogRead(A6));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(35, HIGH);
}
else if (!CV) {
digitalWrite(35, LOW);
}
}
if (button6.wasReleased()) {
myInstrum.pause (true);
// BG == false;
//Kill ControlVoltage
digitalWrite(35, LOW);
}
if (button7.isPressed()) {
// vol = 100/count + 25;
myInstrume.play(true);
// myInstrume.setVolume(vol);
VOL7 = constrain(map(analogRead(A7), TH7, 500, 30, 127), 30, 127);
//myInstrume.setMod(VOL7);
myInstrume.setVolume(VOL7);
// BH == true;
Serial.print("Tone7 active at vol:");
Serial.println(VOL7);
Serial.println(analogRead(A7));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(37, HIGH);
}
else if (!CV) {
digitalWrite(37, LOW);
}
}
if (button7.wasReleased()) {
myInstrume.pause (true);
// BH == false;
//Kill ControlVoltage
digitalWrite(37, LOW);
}
if (button8.isPressed()) {
// vol = 100/count + 25;
myInstrumen.play(true);
// myInstrumen.setVolume(vol);
VOL8 = constrain(map(analogRead(A8), TH8, 500, 30, 127), 30, 127);
//myInstrumen.setMod(VOL8);
myInstrumen.setVolume(VOL8);
// BI == true;
Serial.print("Tone8 active at vol:");
Serial.println(VOL8);
Serial.println(analogRead(A8));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(39, HIGH);
}
else if (!CV) {
digitalWrite(39, LOW);
}
}
if (button8.wasReleased()) {
myInstrumen.pause (true);
// BI == false;
//Kill ControlVoltage
digitalWrite(39, LOW);
}
if (button9.isPressed()) {
// vol = 100/count + 25;
myInstrument.play(true);
// myInstrument.setVolume(vol);
VOL9 = constrain(map(analogRead(A9), TH9, 500, 30, 127), 30, 127);
//myInstrument.setMod(VOL9);
myInstrument.setVolume(VOL9);
// BJ == true;
Serial.print("Tone00 active at vol:");
Serial.println(VOL9);
Serial.println(analogRead(A9));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(41, HIGH);
}
else if (!CV) {
digitalWrite(41, LOW);
}
}
if (button9.wasReleased()) {
myInstrument.pause (true);
// BJ == false;
//Kill ControlVoltage
digitalWrite(41, LOW);
}
}

@ -0,0 +1,564 @@
#include <SensorToButton.h>
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
//note values
const char note1[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note5[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note6[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note7[] PROGMEM = ":d=128,b=300:f+"; //plays f5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:b+"; //plays b5
//instruments
MusicWithoutDelay myI(note1);
MusicWithoutDelay myIn(note2);
MusicWithoutDelay myIns(note3);
MusicWithoutDelay myInst(note4);
MusicWithoutDelay myInstr(note5);
MusicWithoutDelay myInstru(note6);
MusicWithoutDelay myInstrum(note7);
MusicWithoutDelay myInstrume(note8);
MusicWithoutDelay myInstrumen(note9);
MusicWithoutDelay myInstrument(note10);
int count;
//int vol;
//int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9;
bool CV;
bool ZER;
bool ONE;
bool TWO;
bool THR;
bool FOU;
bool FIV;
bool SIX;
bool SEV;
bool EIG;
bool NIN;
SensorToButton button0(TH0, pressUp, 50);
SensorToButton button1(TH1, pressUp, 50);
SensorToButton button2(TH2, pressUp, 50);
SensorToButton button3(TH3, pressUp, 50);
SensorToButton button4(TH4, pressUp, 50);
SensorToButton button5(TH5, pressUp, 50);
SensorToButton button6(TH6, pressUp, 50);
SensorToButton button7(TH7, pressUp, 50);
SensorToButton button8(TH8, pressUp, 50);
SensorToButton button9(TH9, pressUp, 50);
void setup() {
Serial.begin(9600);
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (analogRead(A0) + 20);
TH1 = (analogRead(A1) + 20);
TH2 = (analogRead(A2) + 20);
TH3 = (analogRead(A3) + 20);
TH4 = (analogRead(A4) + 20);
TH5 = (analogRead(A5) + 20);
TH6 = (analogRead(A6) + 20);
TH7 = (analogRead(A7) + 20);
TH8 = (analogRead(A8) + 20);
TH9 = (analogRead(A9) + 20);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
myI.begin(CHA, SINE, ENVELOPE0, 0);
myIn.begin(SINE, ENVELOPE0, 0);
myIns.begin(SINE, ENVELOPE0, 0);
myInst.begin(SINE, ENVELOPE0, 0);
myInstr.begin(SINE, ENVELOPE0, 0);
myInstru.begin(SINE, ENVELOPE0, 0);
myInstrum.begin(SINE, ENVELOPE0, 0);
myInstrume.begin(SINE, ENVELOPE0, 0);
myInstrumen.begin(SINE, ENVELOPE0, 0);
myInstrument.begin(SINE, ENVELOPE0, 0);
myI.pause(true);
myIn.pause(true);
myIns.pause(true);
myInst.pause(true);
myInstr.pause(true);
myInstru.pause(true);
myInstrum.pause(true);
myInstrume.pause(true);
myInstrumen.pause(true);
myInstrument.pause(true);
Serial.println("go!");
}
void loop() {
CV = digitalRead(22);
count = 0;
button0.read (A0);
button1.read (A1);
button2.read (A2);
button3.read (A3);
button4.read (A4);
button5.read (A5);
button6.read (A6);
button7.read (A7);
button8.read (A8);
button9.read (A9);
myI.update();
myIn.update();
myIns.update();
myInst.update();
myInstr.update();
myInstru.update();
myInstrum.update();
myInstrume.update();
myInstrumen.update();
myInstrument.update();
//Messure LDR inputs
// VA0 = analogRead(A0);
// VA1 = analogRead(A1);
// VA2 = analogRead(A2);
// VA3 = analogRead(A3);
//
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
// VA4 = analogRead(A4);
// VA5 = analogRead(A5);
// VA6 = analogRead(A6);
// VA7 = analogRead(A7);
//
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
// VA8 = analogRead(A8);
// VA9 = analogRead(A9);
//
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.println(" ");
if (button0.isPressed()) {
count++;
ZER == true;
}
else {
ZER == false;
}
if (button1.isPressed()) {
count++;
ONE == true;
}
else {
ONE == false;
}
if (button2.isPressed()) {
count++;
TWO == true;
}
else {
TWO == false;
}
if (button3.isPressed()) {
count++;
THR == true;
}
else if{
THR == false;
}
if (button4.isPressed()) {
count++;
FOU == true;
}
else {
FOU == false;
}
if (button5.isPressed()) {
count++;
FIV == true;
}
else {
FIV == false;
}
if (button6.isPressed()) {
count++;
SIX == true;
}
else {
SIX == false;
}
if (button7.isPressed()) {
count++;
SEV == true;
}
else {
SEV == false;
}
if (button8.isPressed()) {
count++;
EIG == true;
}
else {
EIG == false;
}
if (button9.isPressed()) {
count++;
NIN == true;
}
else {
NIN == false;
}
Serial.print("Intruments playing = ");
Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
//vol = 100/count + 25;
myI.play(true);
// myI.setVolume(vol);
VOL0 = constrain(map(analogRead(A0), TH0, 500, 30, 127), 30, 127);
//myI.setMod(VOL0);
myI.setVolume(VOL0);
// BA == true;
Serial.print("Tone0 active at vol:");
Serial.println(VOL0);
Serial.println(analogRead(A0));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(23, HIGH);
}
else if (!CV) {
digitalWrite(23, LOW);
}
}
if (!ZER) {
myI.pause (true);
// BA == false;
//Kill ControlVoltage
digitalWrite(23, LOW);
}
if (ONE) {
// vol = 100/count + 25;
myIn.play(true);
// myIn.setVolume(vol);
VOL1 = constrain(map(analogRead(A1), TH1, 500, 30, 127), 30, 127);
//myIn.setMod(VOL1);
myIn.setVolume(VOL1);
// BB == true;
Serial.print("Tone1 active at vol:");
Serial.println(VOL1);
Serial.println(analogRead(A1));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(25, HIGH);
}
else if (!CV) {
digitalWrite(25, LOW);
}
}
if (!ONE) {
myIn.pause (true);
// BB == false;
//Kill ControlVoltage
digitalWrite(25, LOW);
}
if (TWO) {
// vol = 100/count + 25;
myIns.play(true);
// myIns.setVolume(vol);
VOL2 = constrain(map(analogRead(A2), TH2, 500, 30, 127), 30, 127);
//myIns.setMod(VOL2);
myIns.setVolume(VOL2);
// BC == true;
Serial.print("Tone2 active at vol:");
Serial.println(VOL2);
Serial.println(analogRead(A2));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(27, HIGH);
}
else if (!CV) {
digitalWrite(27, LOW);
}
}
if (!TWO) {
myIns.pause (true);
// BC == false;
//Kill ControlVoltage
digitalWrite(27, LOW);
}
if (THR) {
// vol = 100/count + 25;
myInst.play(true);
// myInst.setVolume(vol);
VOL3 = constrain(map(analogRead(A3), TH3, 500, 30, 127), 30, 127);
//myInst.setMod(VOL3);
myInst.setVolume(VOL3);
// BD == true;
Serial.print("Tone3 active at vol:");
Serial.println(VOL3);
Serial.println(analogRead(A3));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(29, HIGH);
}
else if (!CV) {
digitalWrite(29, LOW);
}
}
if (!THR) {
myInst.pause (true);
// BD == false;
//Kill ControlVoltage
digitalWrite(29, LOW);
}
if (FOU) {
// vol = 100/count + 25;
myInstr.play(true);
// myInstr.setVolume(vol);
VOL4 = constrain(map(analogRead(A4), TH4, 500, 30, 127), 30, 127);
//myInstr.setMod(VOL4);
myInstr.setVolume(VOL4);
// BE == true;
Serial.print("Tone4 active at vol:");
Serial.println(VOL4);
Serial.println(analogRead(A4));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(31, HIGH);
}
else if (!CV) {
digitalWrite(31, LOW);
}
}
if (!FOU) {
myInstr.pause (true);
// BE == false;
//Kill ControlVoltage
digitalWrite(31, LOW);
}
if (FIV) {
// vol = 100/count + 25;
myInstru.play(true);
// myInstru.setVolume(vol);
VOL5 = constrain(map(analogRead(A5), TH5, 500, 30, 127), 30, 127);
//myInstru.setMod(VOL5);
myInstru.setVolume(VOL5);
// BF == true;
Serial.print("Tone5 active at vol:");
Serial.println(VOL5);
Serial.println(analogRead(A5));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(33, HIGH);
}
else if (!CV) {
digitalWrite(33, LOW);
}
}
if (!FIV) {
myInstru.pause (true);
// BF == false;
//Kill ControlVoltage
digitalWrite(33, LOW);
}
if (SIX) {
// vol = 100/count + 25;
myInstrum.play(true);
// myInstrum.setVolume(vol);
VOL6 = constrain(map(analogRead(A6), TH6, 500, 30, 127), 30, 127);
//myInstrum.setMod(VOL6);
myInstrum.setVolume(VOL6);
// BG == true;
Serial.print("Tone6 active at vol:");
Serial.println(VOL6);
Serial.println(analogRead(A6));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(35, HIGH);
}
else if (!CV) {
digitalWrite(35, LOW);
}
}
if (!SIX) {
myInstrum.pause (true);
// BG == false;
//Kill ControlVoltage
digitalWrite(35, LOW);
}
if (SEV) {
// vol = 100/count + 25;
myInstrume.play(true);
// myInstrume.setVolume(vol);
VOL7 = constrain(map(analogRead(A7), TH7, 500, 30, 127), 30, 127);
//myInstrume.setMod(VOL7);
myInstrume.setVolume(VOL7);
// BH == true;
Serial.print("Tone7 active at vol:");
Serial.println(VOL7);
Serial.println(analogRead(A7));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(37, HIGH);
}
else if (!CV) {
digitalWrite(37, LOW);
}
}
if (!SEV) {
myInstrume.pause (true);
// BH == false;
//Kill ControlVoltage
digitalWrite(37, LOW);
}
if (EIG) {
// vol = 100/count + 25;
myInstrumen.play(true);
// myInstrumen.setVolume(vol);
VOL8 = constrain(map(analogRead(A8), TH8, 500, 30, 127), 30, 127);
//myInstrumen.setMod(VOL8);
myInstrumen.setVolume(VOL8);
// BI == true;
Serial.print("Tone8 active at vol:");
Serial.println(VOL8);
Serial.println(analogRead(A8));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(39, HIGH);
}
else if (!CV) {
digitalWrite(39, LOW);
}
}
if (!EIG) {
myInstrumen.pause (true);
// BI == false;
//Kill ControlVoltage
digitalWrite(39, LOW);
}
if (NIN) {
// vol = 100/count + 25;
myInstrument.play(true);
// myInstrument.setVolume(vol);
VOL9 = constrain(map(analogRead(A9), TH9, 500, 30, 127), 30, 127);
//myInstrument.setMod(VOL9);
myInstrument.setVolume(VOL9);
// BJ == true;
Serial.print("Tone00 active at vol:");
Serial.println(VOL9);
Serial.println(analogRead(A9));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(41, HIGH);
}
else if (!CV) {
digitalWrite(41, LOW);
}
}
if (!NIN) {
myInstrument.pause (true);
// BJ == false;
//Kill ControlVoltage
digitalWrite(41, LOW);
}
}

@ -0,0 +1,474 @@
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
//note values
const char note1[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note5[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note6[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note7[] PROGMEM = ":d=128,b=300:f+"; //plays f5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:b+"; //plays b5
//instruments
MusicWithoutDelay myI(note1);
MusicWithoutDelay myIn(note2);
MusicWithoutDelay myIns(note3);
MusicWithoutDelay myInst(note4);
MusicWithoutDelay myInstr(note5);
MusicWithoutDelay myInstru(note6);
MusicWithoutDelay myInstrum(note7);
MusicWithoutDelay myInstrume(note8);
MusicWithoutDelay myInstrumen(note9);
MusicWithoutDelay myInstrument(note10);
int count;
int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9;
bool CV;
bool BA;
bool BB;
bool BC;
bool BD;
bool BE;
bool BF;
bool BG;
bool BH;
bool BI;
bool BJ;
void setup() {
Serial.begin(9600);
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (analogRead(A0)+20);
TH1 = (analogRead(A1)+20);
TH2 = (analogRead(A2)+20);
TH3 = (analogRead(A3)+20);
TH4 = (analogRead(A4)+20);
TH5 = (analogRead(A5)+20);
TH6 = (analogRead(A6)+20);
TH7 = (analogRead(A7)+20);
TH8 = (analogRead(A8)+20);
TH9 = (analogRead(A9)+20);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
myI.begin(CHA, SINE, ENVELOPE0, 0);
myIn.begin(SINE, ENVELOPE0, 0);
myIns.begin(SINE, ENVELOPE0, 0);
myInst.begin(SINE, ENVELOPE0, 0);
myInstr.begin(SINE, ENVELOPE0, 0);
myInstru.begin(SINE, ENVELOPE0, 0);
myInstrum.begin(SINE, ENVELOPE0, 0);
myInstrume.begin(SINE, ENVELOPE0, 0);
myInstrumen.begin(SINE, ENVELOPE0, 0);
myInstrument.begin(SINE, ENVELOPE0, 0);
myI.pause(true);
myIn.pause(true);
myIns.pause(true);
myInst.pause(true);
myInstr.pause(true);
myInstru.pause(true);
myInstrum.pause(true);
myInstrume.pause(true);
myInstrumen.pause(true);
myInstrument.pause(true);
Serial.println("go!");
}
void loop() {
myI.update();
myIn.update();
myIns.update();
myInst.update();
myInstr.update();
myInstru.update();
myInstrum.update();
myInstrume.update();
myInstrumen.update();
myInstrument.update();
//Messure LDR multiplex inputs
VA0 = analogRead(A0);
VA1 = analogRead(A1);
VA2 = analogRead(A2);
VA3 = analogRead(A3);
//
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = analogRead(A4);
VA5 = analogRead(A5);
VA6 = analogRead(A6);
VA7 = analogRead(A7);
//
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = analogRead(A8);
VA9 = analogRead(A9);
//
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.println(" ");
count = 0;
CV = digitalRead(22);
if (VA0 > TH0) {
count++;
}
if (VA1 > TH1) {
count++;
}
if (VA2 > TH2) {
count++;
}
if (VA3 > TH3) {
count++;
}
if (VA4 > TH4) {
count++;
}
if (VA5 > TH5) {
count++;
}
if (VA6 > TH6) {
count++;
}
if (VA7 > TH7) {
count++;
}
if (VA8 > TH8) {
count++;
}
if (VA9 > TH9) {
count++;
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (VA0 > TH0 && !BA) {
vol = 100/count + 25;
myI.play(true);
myI.setVolume(vol);
VOL0 = constrain(map(VA0, TH0, 500, 30, 127), 30, 127);
//myI.setMod(VOL0);
myI.setVolume(VOL0);
BA == true;
// Serial.print("Tone1 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(23, HIGH);
}
else if (!CV) {
digitalWrite(23, LOW);
}
}
else if (VA0 < TH0 && BA) {
myI.pause (true);
BA == false;
//Kill ControlVoltage
digitalWrite(23, LOW);
}
if (VA1 > TH1 && !BB) {
vol = 100/count + 25;
myIn.play(true);
myIn.setVolume(vol);
VOL1 = constrain(map(VA1, TH1, 500, 30, 127), 30, 127);
//myIn.setMod(VOL1);
myIn.setVolume(VOL1);
BB == true;
// Serial.print("Tone2 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(25, HIGH);
}
else if (!CV) {
digitalWrite(25, LOW);
}
}
else if (VA1 < TH1 && BB) {
myIn.pause (true);
BB == false;
//Kill ControlVoltage
digitalWrite(25, LOW);
}
if (VA2 > TH2 && !BC) {
vol = 100/count + 25;
myIns.play(true);
myIns.setVolume(vol);
VOL2 = constrain(map(VA2, TH2, 500, 30, 127), 30, 127);
//myIns.setMod(VOL2);
myIns.setVolume(VOL2);
BC == true;
// Serial.print("Tone3 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(27, HIGH);
}
else if (!CV) {
digitalWrite(27, LOW);
}
}
else if (VA2 < TH2 && BC) {
myIns.pause (true);
BC == false;
//Kill ControlVoltage
digitalWrite(27, LOW);
}
if (VA3 > TH3 && !BD) {
vol = 100/count + 25;
myInst.play(true);
myInst.setVolume(vol);
VOL3 = constrain(map(VA3, TH3, 500, 30, 127), 30, 127);
//myInst.setMod(VOL3);
myInst.setVolume(VOL3);
BD == true;
// Serial.print("Tone4 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(29, HIGH);
}
else if (!CV) {
digitalWrite(29, LOW);
}
}
else if (VA3 < TH3 && BD) {
myInst.pause (true);
BD == false;
//Kill ControlVoltage
digitalWrite(29, LOW);
}
if (VA4 > TH4 && !BE) {
vol = 100/count + 25;
myInstr.play(true);
myInstr.setVolume(vol);
VOL4 = constrain(map(VA4, TH4, 500, 30, 127), 30, 127);
//myInstr.setMod(VOL4);
myInstr.setVolume(VOL4);
BE == true;
// Serial.print("Tone5 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(31, HIGH);
}
else if (!CV) {
digitalWrite(31, LOW);
}
}
else if (VA4 < TH4 && BE) {
myInstr.pause (true);
BE == false;
//Kill ControlVoltage
digitalWrite(31, LOW);
}
if (VA5 > TH5 && !BF) {
vol = 100/count + 25;
myInstru.play(true);
myInstru.setVolume(vol);
VOL5 = constrain(map(VA5, TH5, 500, 30, 127), 30, 127);
//myInstru.setMod(VOL5);
myInstru.setVolume(VOL5);
BF == true;
// Serial.print("Tone6 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(33, HIGH);
}
else if (!CV) {
digitalWrite(33, LOW);
}
}
else if (VA5 < TH5 && BF) {
myInstru.pause (true);
BF == false;
//Kill ControlVoltage
digitalWrite(33, LOW);
}
if (VA6 > TH6 && !BG) {
vol = 100/count + 25;
myInstrum.play(true);
myInstrum.setVolume(vol);
VOL6 = constrain(map(VA6, TH6, 500, 30, 127),30, 127);
//myInstrum.setMod(VOL6);
myInstrum.setVolume(VOL6);
BG == true;
// Serial.print("Tone7 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(35, HIGH);
}
else if (!CV) {
digitalWrite(35, LOW);
}
}
else if (VA6 < TH6 && BG) {
myInstrum.pause (true);
BG == false;
//Kill ControlVoltage
digitalWrite(35, LOW);
}
if (VA7 > TH7 && !BH) {
vol = 100/count + 25;
myInstrume.play(true);
myInstrume.setVolume(vol);
VOL7 = constrain(map(VA7, TH7, 500, 30, 127), 30, 127);
//myInstrume.setMod(VOL7);
myInstrume.setVolume(VOL7);
BH == true;
// Serial.print("Tone8 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(37, HIGH);
}
else if (!CV) {
digitalWrite(37, LOW);
}
}
else if (VA7 < TH7 && BH) {
myInstrume.pause (true);
BH == false;
//Kill ControlVoltage
digitalWrite(37, LOW);
}
if (VA8 > TH8 && !BI) {
vol = 100/count + 25;
myInstrumen.play(true);
myInstrumen.setVolume(vol);
VOL8 = constrain(map(VA8, TH8, 500, 30, 127), 30, 127);
//myInstrumen.setMod(VOL8);
myInstrumen.setVolume(VOL8);
BI == true;
// Serial.print("Tone9 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(39, HIGH);
}
else if (!CV) {
digitalWrite(39, LOW);
}
}
else if (VA8 < TH8 && BI) {
myInstrumen.pause (true);
BI == false;
//Kill ControlVoltage
digitalWrite(39, LOW);
}
if (VA9 > TH9 && !BJ) {
vol = 100/count + 25;
myInstrument.play(true);
myInstrument.setVolume(vol);
VOL9 = constrain(map(VA9, TH9, 500, 30, 127), 30, 127);
//myInstrument.setMod(VOL9);
myInstrument.setVolume(VOL9);
BJ == true;
// Serial.print("Tone10 active at vol:");
// Serial.println(vol);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(41, HIGH);
}
else if (!CV) {
digitalWrite(41, LOW);
}
}
else if (VA9 < TH9 && BJ) {
myInstrument.pause (true);
BJ == false;
//Kill ControlVoltage
digitalWrite(41, LOW);
}
}

@ -0,0 +1,494 @@
//#include <SensorToButton.h>
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
//note values
const char note0[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=300:d-1+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:a-1+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
//instruments
MusicWithoutDelay myI(note0);
MusicWithoutDelay myIn(note1);
MusicWithoutDelay myIns(note2);
MusicWithoutDelay myInst(note3);
MusicWithoutDelay myInstr(note4);
MusicWithoutDelay myInstru(note5);
MusicWithoutDelay myInstrum(note6);
MusicWithoutDelay myInstrume(note7);
MusicWithoutDelay myInstrumen(note8);
MusicWithoutDelay myInstrument(note9);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9;
bool CV;
bool ZER;
bool ONE;
bool TWO;
bool THR;
bool FOU;
bool FIV;
bool SIX;
bool SEV;
bool EIG;
bool NIN;
void setup() {
Serial.begin(9600);
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (analogRead(A0) + 40);
TH1 = (analogRead(A1) + 40);
TH2 = (analogRead(A2) + 40);
TH3 = (analogRead(A3) + 40);
TH4 = (analogRead(A4) + 40);
TH5 = (analogRead(A5) + 40);
TH6 = (analogRead(A6) + 40);
TH7 = (analogRead(A7) + 40);
TH8 = (analogRead(A8) + 40);
TH9 = (analogRead(A9) + 40);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
myI.begin(CHA, TRIANGLE, ENVELOPE0, 0);
myIn.begin(TRIANGLE, ENVELOPE0, 0);
myIns.begin(TRIANGLE, ENVELOPE0, 0);
myInst.begin(TRIANGLE, ENVELOPE0, 0);
myInstr.begin(TRIANGLE, ENVELOPE0, 0);
myInstru.begin(TRIANGLE, ENVELOPE0, 0);
myInstrum.begin(TRIANGLE, ENVELOPE0, 0);
myInstrume.begin(TRIANGLE, ENVELOPE0, 0);
myInstrumen.begin(TRIANGLE, ENVELOPE0, 0);
myInstrument.begin(TRIANGLE, ENVELOPE0, 0);
myI.pause(true);
myIn.pause(true);
myIns.pause(true);
myInst.pause(true);
myInstr.pause(true);
myInstru.pause(true);
myInstrum.pause(true);
myInstrume.pause(true);
myInstrumen.pause(true);
myInstrument.pause(true);
Serial.println("go!");
}
void loop() {
CV = digitalRead(22);
count = 0;
myI.update();
myIn.update();
myIns.update();
myInst.update();
myInstr.update();
myInstru.update();
myInstrum.update();
myInstrume.update();
myInstrumen.update();
myInstrument.update();
//Messure LDR inputs
VA0 = analogRead(A0);
VA1 = analogRead(A1);
VA2 = analogRead(A2);
VA3 = analogRead(A3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = analogRead(A4);
VA5 = analogRead(A5);
VA6 = analogRead(A6);
VA7 = analogRead(A7);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = analogRead(A8);
VA9 = analogRead(A9);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.println(" ");
if (VA0 > TH0) {
count++;
ZER = true;
}
else if (VA0 < TH0) {
ZER = false;
}
if (VA1 > TH1) {
count++;
ONE = true;
}
else if (VA1 < TH1) {
ONE = false;
}
if (VA2 > TH2) {
count++;
TWO = true;
}
else if (VA2 < TH2) {
TWO = false;
}
if (VA3 > TH3) {
count++;
THR = true;
}
else if (VA3 < TH3) {
THR = false;
}
if (VA4 > TH4) {
count++;
FOU = true;
}
else if (VA4 < TH4) {
FOU = false;
}
if (VA5 > TH5) {
count++;
FIV = true;
}
else if (VA5 < TH5) {
FIV = false;
}
if (VA6 > TH6) {
count++;
SIX = true;
}
else if (VA6 < TH6) {
SIX = false;
}
if (VA7 > TH7) {
count++;
SEV = true;
}
else if (VA7 < TH7) {
SEV = false;
}
if (VA8 > TH8) {
count++;
EIG = true;
}
else if (VA8 < TH8) {
EIG = false;
}
if (VA9 > TH9) {
count++;
NIN = true;
}
else if (VA9 < TH9) {
NIN = false;
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
myI.play(true);
VOL0 = 50/count+constrain(map(analogRead(A0), TH0, TH0+450, 0, 50), 0, 50);
myI.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(analogRead(A0));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(23, HIGH);
}
else if (!CV) {
digitalWrite(23, LOW);
}
}
if (!ZER) {
myI.pause (true);
//Kill ControlVoltage
digitalWrite(23, LOW);
}
if (ONE) {
myIn.play(true);
VOL1 = 50/count+constrain(map(analogRead(A1), TH1, TH1+450, 0, 50), 0, 50);
myIn.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(analogRead(A1));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(25, HIGH);
}
else if (!CV) {
digitalWrite(25, LOW);
}
}
if (!ONE) {
myIn.pause (true);
//Kill ControlVoltage
digitalWrite(25, LOW);
}
if (TWO) {
myIns.play(true);
VOL2 = 50/count+constrain(map(analogRead(A2), TH2, TH2+450, 0, 50), 0, 50);
myIns.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(analogRead(A2));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(27, HIGH);
}
else if (!CV) {
digitalWrite(27, LOW);
}
}
if (!TWO) {
myIns.pause (true);
//Kill ControlVoltage
digitalWrite(27, LOW);
}
if (THR) {
myInst.play(true);
VOL3 = 50/count+constrain(map(analogRead(A3), TH3, TH3+450, 0, 50), 0, 50);
myInst.setVolume(VOL3);
// BD == true;
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(analogRead(A3));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(29, HIGH);
}
else if (!CV) {
digitalWrite(29, LOW);
}
}
if (!THR) {
myInst.pause (true);
//Kill ControlVoltage
digitalWrite(29, LOW);
}
if (FOU) {
myInstr.play(true);
VOL4 = 50/count+constrain(map(analogRead(A4), TH4, TH4+450, 0, 50), 0, 50);
myInstr.setVolume(VOL4);
// BE == true;
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(analogRead(A4));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(31, HIGH);
}
else if (!CV) {
digitalWrite(31, LOW);
}
}
if (!FOU) {
myInstr.pause (true);
//Kill ControlVoltage
digitalWrite(31, LOW);
}
if (FIV) {
myInstru.play(true);
VOL5 = 50/count+constrain(map(analogRead(A5), TH5, TH5+450, 0, 50), 0, 50);
//myInstru.setMod(VOL5);
myInstru.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(analogRead(A5));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(33, HIGH);
}
else if (!CV) {
digitalWrite(33, LOW);
}
}
if (!FIV) {
myInstru.pause (true);
//Kill ControlVoltage
digitalWrite(33, LOW);
}
if (SIX) {
myInstrum.play(true);
VOL6 = 50/count+constrain(map(analogRead(A6), TH6, TH6+450, 0, 50), 0, 50);
//myInstrum.setMod(VOL6);
myInstrum.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(analogRead(A6));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(35, HIGH);
}
else if (!CV) {
digitalWrite(35, LOW);
}
}
if (!SIX) {
myInstrum.pause (true);
//Kill ControlVoltage
digitalWrite(35, LOW);
}
if (SEV) {
myInstrume.play(true);
VOL7 = 50/count+constrain(map(analogRead(A7), TH7, TH7+450, 0, 50), 0, 50);
myInstrume.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(analogRead(A7));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(37, HIGH);
}
else if (!CV) {
digitalWrite(37, LOW);
}
}
if (!SEV) {
myInstrume.pause (true);
//Kill ControlVoltage
digitalWrite(37, LOW);
}
if (EIG) {
myInstrumen.play(true);
VOL8 = 50/count+constrain(map(analogRead(A8), TH8, TH8+450, 0, 50), 0, 50);
myInstrumen.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(analogRead(A8));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(39, HIGH);
}
else if (!CV) {
digitalWrite(39, LOW);
}
}
if (!EIG) {
myInstrumen.pause (true);
//Kill ControlVoltage
digitalWrite(39, LOW);
}
if (NIN) {
myInstrument.play(true);
VOL9 = 50/count+constrain(map(analogRead(A9), TH9, TH9+450, 0, 50), 0, 50);
myInstrument.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(analogRead(A9));
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(41, HIGH);
}
else if (!CV) {
digitalWrite(41, LOW);
}
}
if (!NIN) {
myInstrument.pause (true);
//Kill ControlVoltage
digitalWrite(41, LOW);
}
}

@ -0,0 +1,341 @@
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note1[] PROGMEM = {"::c-1"}; //plays c4
const char note2[] PROGMEM = {"::e-1"}; //plays e4
const char note3[] PROGMEM = {"::f-1"}; //plays f4
const char note4[] PROGMEM = {"::g-1"}; //plays g4
const char note5[] PROGMEM = {"::c"}; //plays c5
const char note6[] PROGMEM = {"::e"}; //plays e5
const char note7[] PROGMEM = {"::f"}; //plays f5
const char note8[] PROGMEM = {"::g"}; //plays g5
//const char note9[] PROGMEM = {"::c+1"}; //plays c6
//const char note10[] PROGMEM = {"::e+1"}; //plays e6
//const char note11[] PROGMEM = {"::f+1"}; //plays f6
//const char note12[] PROGMEM = {"::g+1"}; //plays g6
//instruments
MusicWithoutDelay myI(note1);
MusicWithoutDelay myIn(note2);
MusicWithoutDelay myIns(note3);
MusicWithoutDelay myInst(note4);
MusicWithoutDelay myInstr(note5);
MusicWithoutDelay myInstru(note6);
MusicWithoutDelay myInstrum(note7);
MusicWithoutDelay myInstrume(note8);
//MusicWithoutDelay myInstrumen(note9);
//MusicWithoutDelay myInstrument(note10);
//MusicWithoutDelay myInstruments(note11);
//MusicWithoutDelay myInstrumentss(note12);
int count;
int vol;
int TH;
int16_t adc0a, adc1a, adc2a, adc3a, adc0b, adc1b, adc2b, adc3b, adc0c, adc1c, adc2c, adc3c, adc0d, adc1d, adc2d, adc3d;
//bool codeswitch = false;
bool BA;
bool BB;
bool BC;
bool BD;
bool BE;
bool BF;
bool BG;
bool BH;
void setup() {
Serial.begin(115200);
//set the gain for multiplexed ins
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
//start the multiplexing
Serial.println("Initializing Multiplexing ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("Multiplexing Initialized");
//calibrate the LDRs
Serial.println ("Calibrating");
TH = (adsb.readADC_SingleEnded(3));
Serial.print ("TH=");
Serial.println (TH);
Serial.println("Initializing Music Without Delay");
myI.begin(CHA, TRIANGLE, ENVELOPE0, 0);
myIn.begin(TRIANGLE, ENVELOPE0, 0);
myIns.begin(TRIANGLE, ENVELOPE0, 0);
myInst.begin(TRIANGLE, ENVELOPE0, 0);
Serial.println("Music Witout Delay Initialized");
Serial.println("Start messuring LDRs");
}
void loop() {
// myI.update();
// myIn.update();
// myIns.update();
// myInst.update();
//Messure LDR multiplex inputs
adc0a = adsa.readADC_SingleEnded(0);
adc1a = adsa.readADC_SingleEnded(1);
adc2a = adsa.readADC_SingleEnded(2);
adc3a = adsa.readADC_SingleEnded(3);
Serial.print("AIN0A: "); Serial.println(adc0a);
Serial.print("AIN1A: "); Serial.println(adc1a);
Serial.print("AIN2A: "); Serial.println(adc2a);
Serial.print("AIN3A: "); Serial.println(adc3a);
Serial.println(" ");
adc0b = adsb.readADC_SingleEnded(0);
adc1b = adsb.readADC_SingleEnded(1);
adc2b = adsb.readADC_SingleEnded(2);
adc3b = adsb.readADC_SingleEnded(3);
Serial.print("AIN0B: "); Serial.println(adc0b);
Serial.print("AIN1B: "); Serial.println(adc1b);
Serial.print("AIN2B: "); Serial.println(adc2b);
Serial.print("AIN3B: "); Serial.println(adc3b);
Serial.println(" ");
adc0c = adsc.readADC_SingleEnded(0);
adc1c = adsc.readADC_SingleEnded(1);
adc2c = adsc.readADC_SingleEnded(2);
adc3c = adsc.readADC_SingleEnded(3);
Serial.print("AIN0C: "); Serial.println(adc0c);
Serial.print("AIN1C: "); Serial.println(adc1c);
Serial.print("AIN2C: "); Serial.println(adc2c);
Serial.print("AIN3C: "); Serial.println(adc3c);
Serial.println(" ");
adc0d = adsd.readADC_SingleEnded(0);
adc1d = adsd.readADC_SingleEnded(1);
adc2d = adsd.readADC_SingleEnded(2);
adc3d = adsd.readADC_SingleEnded(3);
Serial.print("AIN0D: "); Serial.println(adc0d);
Serial.print("AIN1D: "); Serial.println(adc1d);
Serial.print("AIN2D: "); Serial.println(adc2d);
Serial.print("AIN3D: "); Serial.println(adc3d);
Serial.println(" ");
count = 0;
if (adc0a < TH) {
count++;
}
if (adc1a < TH) {
count++;
}
if (adc2a < TH) {
count++;
}
if (adc3a < TH) {
count++;
}
if (adc0b < TH) {
count++;
}
if (adc1b < TH) {
count++;
}
if (adc2b < TH) {
count++;
}
if (adc3b < TH) {
count++;
}
// if (adc0c < TH) {
// count++;
// }
// if (adc1c < TH) {
// count++;
// }
// if (adc2c < TH) {
// count++;
// }
// if (adc3c < TH) {
// count++;
// }
Serial.print("Intruments playing=");
Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (adc0a < TH && !BA) {
vol = 120/count;
myI.play(true);
myI.setVolume(vol);
// myI.setSustain(50);
//myI.setMod(int mod1 = map(adc0a, 3000, 60000, 0, 127);
BA == true;
Serial.print("Tone1 active at vol:");
Serial.println(vol);
}
else if (adc0a > TH && BA) {
myI.pause (true);
BA == false;
Serial.println("Tone1 not active");
}
if (adc1a < TH && !BB) {
vol = 120/count;
myIn.play(true);
myIn.setVolume(vol);
// myIn.setSustain(50);
BB == true;
Serial.print("Tone2 active at vol:");
Serial.println(vol);
}
else if (adc1a > TH && BB) {
myIn.pause (true);
BB == false;
Serial.println("Tone2 not active");
}
if (adc2a < TH && !BC) {
vol = 120/count;
myIns.play(true);
myIns.setVolume(vol);
// myIns.setSustain(50);
BC == true;
Serial.print("Tone3 active at vol:");
Serial.println(vol);
}
else if (adc2a > TH && BC) {
myIns.pause (true);
BC == false;
Serial.println("Tone3 not active");
}
if (adc3a < TH && !BD) {
vol = 120/count;
myInst.play(true);
myInst.setVolume(vol);
// myInst.setSustain(50);
BD == true;
Serial.print("Tone4 active at vol:");
Serial.println(vol);
}
else if (adc3a < TH && BD) {
myInst.pause (true);
BD == false;
Serial.println("Tone4 not active");
}
if (adc0b < TH && !BE) {
vol = 120/count;
myInstr.play(true);
myInstr.setVolume(vol);
// myInst.setSustain(50);
BE == true;
Serial.print("Tone5 active at vol:");
Serial.println(vol);
}
else if (adc0b < TH && BE) {
myInstr.pause (true);
BE == false;
Serial.println("Tone5 not active");
}
if (adc1b < TH && !BF) {
vol = 120/count;
myInstru.play(true);
myInstru.setVolume(vol);
// myInst.setSustain(50);
BF == true;
Serial.print("Tone6 active at vol:");
Serial.println(vol);
}
else if (adc1b < TH && BF) {
myInstru.pause (true);
BF == false;
Serial.println("Tone6 not active");
}
if (adc2b < TH && !BG) {
vol = 120/count;
myInstrum.play(true);
myInstrum.setVolume(vol);
// myInst.setSustain(50);
BG == true;
Serial.print("Tone7 active at vol:");
Serial.println(vol);
}
else if (adc2b < TH && BG) {
myInstrum.pause (true);
BG == false;
Serial.println("Tone7 not active");
}
if (adc3b < TH && !BH) {
vol = 120/count;
myInstrume.play(true);
myInstrume.setVolume(vol);
// myInst.setSustain(50);
BH == true;
Serial.print("Tone8 active at vol:");
Serial.println(vol);
}
else if (adc3b < TH && BH) {
myInstrume.pause (true);
BH == false;
Serial.println("Tone8 not active");
}
// if (adc0b < TH) {
// //result += tone_5.next() * (1/count);
// }
// if (adc1b < TH) {
// //result += tone_6.next() * (1/count);
// }
// if (adc2b < TH) {
// //result += tone_7.next() * (1/count);
// }
// if (adc3b < TH) {
// //result += tone_8.next() * (1/count);
// }
// if (adc0c < TH) {
// //result += tone_9.next() * (1/count);
// }
// if (adc1c < TH) {
// //result += tone_10.next() * (1/count);
// }
// if (adc2c < TH) {
// //result += tone_11.next() * (1/count);
// }
// if (adc3c < TH) {
// //result += tone_12.next() * (1/count);
// }
}

@ -0,0 +1,331 @@
#include <MusicWithoutDelay.h>
//#include <synth.h>
//#include <tables.h>
// #include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
//Adafruit_ADS1115 adsc (0x4A);
//Adafruit_ADS1115 adsd (0x4B);
//note values
const char note1[] PROGMEM = "::c"; //plays c
const char note2[] PROGMEM = "::e"; //plays e
const char note3[] PROGMEM = "::f"; //plays f
const char note4[] PROGMEM = "::g"; //plays g
//const char note5[] PROGMEM = {"::c"}; //plays c
//const char note6[] PROGMEM = {"::e"}; //plays e
//const char note7[] PROGMEM = {"::f"}; //plays f
//const char note8[] PROGMEM = {"::g"}; //plays g
//const char note9[] PROGMEM = {"::c+1"}; //plays c6
//const char note10[] PROGMEM = {"::e+1"}; //plays e6
//const char note11[] PROGMEM = {"::f+1"}; //plays f6
//const char note12[] PROGMEM = {"::g+1"}; //plays g6
//instruments
MusicWithoutDelay myI(note1);
MusicWithoutDelay myIn(note2);
MusicWithoutDelay myIns(note3);
MusicWithoutDelay myInst(note4);
//MusicWithoutDelay myInstr(note5);
//MusicWithoutDelay myInstru(note6);
//MusicWithoutDelay myInstrum(note7);
//MusicWithoutDelay myInstrume(note8);
//MusicWithoutDelay myInstrumen(note9);
//MusicWithoutDelay myInstrument(note10);
//MusicWithoutDelay myInstruments(note11);
//MusicWithoutDelay myInstrumentss(note12);
int count;
int vol;
int TH;
int16_t adc0a, adc1a, adc2a, adc3a, adc0b, adc1b, adc2b, adc3b, adc0c, adc1c, adc2c, adc3c, adc0d, adc1d, adc2d, adc3d;
//bool codeswitch = false;
bool BA;
bool BB;
bool BC;
bool BD;
//bool BE;
//bool BF;
//bool BG;
//bool BH;
void setup() {
Serial.begin(9600);
//set the gain for multiplexed ins
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
// adsc.setGain(GAIN_ONE);
// adsd.setGain(GAIN_ONE);
//start the multiplexing
Serial.println("Initializing Multiplexing ");
adsa.begin();
adsb.begin();
// adsc.begin();
// adsd.begin();
Serial.println("Multiplexing Initialized");
//calibrate the LDRs
Serial.println ("Calibrating");
TH = (adsb.readADC_SingleEnded(3)/*-500*/);
Serial.print ("TH=");
Serial.println (TH);
Serial.println("Waiting for Music Without Delay");
Serial.println("Initializing Music Without Delay");
myI.begin(CHA, TRIANGLE, ENVELOPE0, 0);
myIn.begin(TRIANGLE, ENVELOPE0, 0);
myIns.begin(TRIANGLE, ENVELOPE0, 0);
myInst.begin(TRIANGLE, ENVELOPE0, 0);
// myInstr.begin(TRIANGLE, ENVELOPE0, 0);
// myInstru.begin(TRIANGLE, ENVELOPE0, 0);
// myInstrum.begin(TRIANGLE, ENVELOPE0, 0);
// myInstrume.begin(TRIANGLE, ENVELOPE0, 0);
Serial.println("Music Witout Delay Initialized");
Serial.println("Start messuring LDRs");
}
void loop() {
myI.update();
myIn.update();
myIns.update();
myInst.update();
// myInstr.update();
// myInstru.update();
// myInstrum.update();
// myInstrume.update();
//Messure LDR multiplex inputs
adc0a = adsa.readADC_SingleEnded(0);
adc1a = adsa.readADC_SingleEnded(1);
adc2a = adsa.readADC_SingleEnded(2);
adc3a = adsa.readADC_SingleEnded(3);
Serial.print("AIN0A: "); Serial.println(adc0a);
Serial.print("AIN1A: "); Serial.println(adc1a);
Serial.print("AIN2A: "); Serial.println(adc2a);
Serial.print("AIN3A: "); Serial.println(adc3a);
Serial.println(" ");
adc0b = adsb.readADC_SingleEnded(0);
adc1b = adsb.readADC_SingleEnded(1);
adc2b = adsb.readADC_SingleEnded(2);
adc3b = adsb.readADC_SingleEnded(3);
Serial.print("AIN0B: "); Serial.println(adc0b);
Serial.print("AIN1B: "); Serial.println(adc1b);
Serial.print("AIN2B: "); Serial.println(adc2b);
Serial.print("AIN3B: "); Serial.println(adc3b);
Serial.println(" ");
// adc0c = adsc.readADC_SingleEnded(0);
// adc1c = adsc.readADC_SingleEnded(1);
// adc2c = adsc.readADC_SingleEnded(2);
// adc3c = adsc.readADC_SingleEnded(3);
//
// Serial.print("AIN0C: "); Serial.println(adc0c);
// Serial.print("AIN1C: "); Serial.println(adc1c);
// Serial.print("AIN2C: "); Serial.println(adc2c);
// Serial.print("AIN3C: "); Serial.println(adc3c);
// Serial.println(" ");
//
// adc0d = adsd.readADC_SingleEnded(0);
// adc1d = adsd.readADC_SingleEnded(1);
// adc2d = adsd.readADC_SingleEnded(2);
// adc3d = adsd.readADC_SingleEnded(3);
//
// Serial.print("AIN0D: "); Serial.println(adc0d);
// Serial.print("AIN1D: "); Serial.println(adc1d);
// Serial.print("AIN2D: "); Serial.println(adc2d);
// Serial.print("AIN3D: "); Serial.println(adc3d);
// Serial.println(" ");
count = 0;
if (adc0a > TH) {
count++;
}
if (adc1a > TH) {
count++;
}
if (adc2a > TH) {
count++;
}
if (adc3a > TH) {
count++;
}
// if (adc0b > TH) {
// count++;
// }
// if (adc1b > TH) {
// count++;
// }
// if (adc2b > TH) {
// count++;
// }
// if (adc3b > TH) {
// count++;
// }
// if (adc0c > TH) {
// count++;
// }
// if (adc1c > TH) {
// count++;
// }
// if (adc2c > TH) {
// count++;
// }
// if (adc3c >TH) {
// count++;
// }
Serial.print("Intruments playing = ");
Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (adc0a > TH && !BA) {
vol = 125/count;
myI.play(true);
myI.setVolume(vol);
//myI.setSustain(100);
//myI.setMod(int mod1 = map(adc0a, 1000, 8000, 0, 127);
BA == true;
Serial.print("Tone1 active at vol:");
Serial.println(vol);
}
else if (adc0a < TH && BA) {
myI.pause (true);
BA == false;
Serial.println("Tone1 not active");
}
if (adc1a > TH && !BB) {
vol = 125/count;
myIn.play(true);
myIn.setVolume(vol);
//myIn.setSustain(100);
BB == true;
Serial.print("Tone2 active at vol:");
Serial.println(vol);
}
else if (adc1a < TH && BB) {
myIn.pause (true);
BB == false;
Serial.println("Tone2 not active");
}
if (adc2a > TH && !BC) {
vol = 125/count;
myIns.play(true);
myIns.setVolume(vol);
//myIns.setSustain(100);
BC == true;
Serial.print("Tone3 active at vol:");
Serial.println(vol);
}
else if (adc2a < TH && BC) {
myIns.pause (true);
BC == false;
Serial.println("Tone3 not active");
}
if (adc3a > TH && !BD) {
vol = 125/count;
myInst.play(true);
myInst.setVolume(vol);
//myInst.setSustain(100);
BD == true;
Serial.print("Tone4 active at vol:");
Serial.println(vol);
}
else if (adc3a < TH && BD) {
myInst.pause (true);
BD == false;
Serial.println("Tone4 not active");
}
// if (adc0b > TH && !BE) {
// vol = 120/count;
// myInstr.play(true);
// myInstr.setVolume(vol);
//// myInst.setSustain(50);
// BE == true;
// Serial.print("Tone5 active at vol:");
// Serial.println(vol);
// }
//
// else if (adc0b < TH && BE) {
// myInstr.pause (true);
// BE == false;
// Serial.println("Tone5 not active");
// }
//
// if (adc1b > TH && !BF) {
// vol = 120/count;
// myInstru.play(true);
// myInstru.setVolume(vol);
//// myInst.setSustain(50);
// BF == true;
// Serial.print("Tone6 active at vol:");
// Serial.println(vol);
// }
//
// else if (adc1b < TH && BF) {
// myInstru.pause (true);
// BF == false;
// Serial.println("Tone6 not active");
// }
//
//
// if (adc2b > TH && !BG) {
// vol = 120/count;
// myInstrum.play(true);
// myInstrum.setVolume(vol);
//// myInst.setSustain(50);
// BG == true;
// Serial.print("Tone7 active at vol:");
// Serial.println(vol);
// }
//
// else if (adc2b < TH && BG) {
// myInstrum.pause (true);
// BG == false;
// Serial.println("Tone7 not active");
// }
//
// if (adc3b > TH && !BH) {
// vol = 120/count;
// myInstrume.play(true);
// myInstrume.setVolume(vol);
//// myInst.setSustain(50);
// BH == true;
// Serial.print("Tone8 active at vol:");
// Serial.println(vol);
// }
//
// else if (adc3b < TH && BH) {
// myInstrume.pause (true);
// BH == false;
// Serial.println("Tone8 not active");
// }
}

@ -0,0 +1,150 @@
/**************************************************************************/
/*!
@file Adafruit_ADS1015.h
@author K. Townsend (Adafruit Industries)
@license BSD (see license.txt)
This is a library for the Adafruit ADS1015 breakout board
----> https://www.adafruit.com/products/???
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
v1.1 - Added ADS1115 support - W. Earl
*/
/**************************************************************************/
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
#include <Wire.h>
/*=========================================================================
I2C ADDRESS/BITS
-----------------------------------------------------------------------*/
#define ADS1015_ADDRESS (0x48) // 1001 000 (ADDR = GND)
/*=========================================================================*/
/*=========================================================================
CONVERSION DELAY (in mS)
-----------------------------------------------------------------------*/
#define ADS1015_CONVERSIONDELAY (1)
#define ADS1115_CONVERSIONDELAY (8)
/*=========================================================================*/
/*=========================================================================
POINTER REGISTER
-----------------------------------------------------------------------*/
#define ADS1015_REG_POINTER_MASK (0x03)
#define ADS1015_REG_POINTER_CONVERT (0x00)
#define ADS1015_REG_POINTER_CONFIG (0x01)
#define ADS1015_REG_POINTER_LOWTHRESH (0x02)
#define ADS1015_REG_POINTER_HITHRESH (0x03)
/*=========================================================================*/
/*=========================================================================
CONFIG REGISTER
-----------------------------------------------------------------------*/
#define ADS1015_REG_CONFIG_OS_MASK (0x8000)
#define ADS1015_REG_CONFIG_OS_SINGLE (0x8000) // Write: Set to start a single-conversion
#define ADS1015_REG_CONFIG_OS_BUSY (0x0000) // Read: Bit = 0 when conversion is in progress
#define ADS1015_REG_CONFIG_OS_NOTBUSY (0x8000) // Read: Bit = 1 when device is not performing a conversion
#define ADS1015_REG_CONFIG_MUX_MASK (0x7000)
#define ADS1015_REG_CONFIG_MUX_DIFF_0_1 (0x0000) // Differential P = AIN0, N = AIN1 (default)
#define ADS1015_REG_CONFIG_MUX_DIFF_0_3 (0x1000) // Differential P = AIN0, N = AIN3
#define ADS1015_REG_CONFIG_MUX_DIFF_1_3 (0x2000) // Differential P = AIN1, N = AIN3
#define ADS1015_REG_CONFIG_MUX_DIFF_2_3 (0x3000) // Differential P = AIN2, N = AIN3
#define ADS1015_REG_CONFIG_MUX_SINGLE_0 (0x4000) // Single-ended AIN0
#define ADS1015_REG_CONFIG_MUX_SINGLE_1 (0x5000) // Single-ended AIN1
#define ADS1015_REG_CONFIG_MUX_SINGLE_2 (0x6000) // Single-ended AIN2
#define ADS1015_REG_CONFIG_MUX_SINGLE_3 (0x7000) // Single-ended AIN3
#define ADS1015_REG_CONFIG_PGA_MASK (0x0E00)
#define ADS1015_REG_CONFIG_PGA_6_144V (0x0000) // +/-6.144V range = Gain 2/3
#define ADS1015_REG_CONFIG_PGA_4_096V (0x0200) // +/-4.096V range = Gain 1
#define ADS1015_REG_CONFIG_PGA_2_048V (0x0400) // +/-2.048V range = Gain 2 (default)
#define ADS1015_REG_CONFIG_PGA_1_024V (0x0600) // +/-1.024V range = Gain 4
#define ADS1015_REG_CONFIG_PGA_0_512V (0x0800) // +/-0.512V range = Gain 8
#define ADS1015_REG_CONFIG_PGA_0_256V (0x0A00) // +/-0.256V range = Gain 16
#define ADS1015_REG_CONFIG_MODE_MASK (0x0100)
#define ADS1015_REG_CONFIG_MODE_CONTIN (0x0000) // Continuous conversion mode
#define ADS1015_REG_CONFIG_MODE_SINGLE (0x0100) // Power-down single-shot mode (default)
#define ADS1015_REG_CONFIG_DR_MASK (0x00E0)
#define ADS1015_REG_CONFIG_DR_128SPS (0x0000) // 128 samples per second
#define ADS1015_REG_CONFIG_DR_250SPS (0x0020) // 250 samples per second
#define ADS1015_REG_CONFIG_DR_490SPS (0x0040) // 490 samples per second
#define ADS1015_REG_CONFIG_DR_920SPS (0x0060) // 920 samples per second
#define ADS1015_REG_CONFIG_DR_1600SPS (0x0080) // 1600 samples per second (default)
#define ADS1015_REG_CONFIG_DR_2400SPS (0x00A0) // 2400 samples per second
#define ADS1015_REG_CONFIG_DR_3300SPS (0x00C0) // 3300 samples per second
#define ADS1015_REG_CONFIG_CMODE_MASK (0x0010)
#define ADS1015_REG_CONFIG_CMODE_TRAD (0x0000) // Traditional comparator with hysteresis (default)
#define ADS1015_REG_CONFIG_CMODE_WINDOW (0x0010) // Window comparator
#define ADS1015_REG_CONFIG_CPOL_MASK (0x0008)
#define ADS1015_REG_CONFIG_CPOL_ACTVLOW (0x0000) // ALERT/RDY pin is low when active (default)
#define ADS1015_REG_CONFIG_CPOL_ACTVHI (0x0008) // ALERT/RDY pin is high when active
#define ADS1015_REG_CONFIG_CLAT_MASK (0x0004) // Determines if ALERT/RDY pin latches once asserted
#define ADS1015_REG_CONFIG_CLAT_NONLAT (0x0000) // Non-latching comparator (default)
#define ADS1015_REG_CONFIG_CLAT_LATCH (0x0004) // Latching comparator
#define ADS1015_REG_CONFIG_CQUE_MASK (0x0003)
#define ADS1015_REG_CONFIG_CQUE_1CONV (0x0000) // Assert ALERT/RDY after one conversions
#define ADS1015_REG_CONFIG_CQUE_2CONV (0x0001) // Assert ALERT/RDY after two conversions
#define ADS1015_REG_CONFIG_CQUE_4CONV (0x0002) // Assert ALERT/RDY after four conversions
#define ADS1015_REG_CONFIG_CQUE_NONE (0x0003) // Disable the comparator and put ALERT/RDY in high state (default)
/*=========================================================================*/
typedef enum
{
GAIN_TWOTHIRDS = ADS1015_REG_CONFIG_PGA_6_144V,
GAIN_ONE = ADS1015_REG_CONFIG_PGA_4_096V,
GAIN_TWO = ADS1015_REG_CONFIG_PGA_2_048V,
GAIN_FOUR = ADS1015_REG_CONFIG_PGA_1_024V,
GAIN_EIGHT = ADS1015_REG_CONFIG_PGA_0_512V,
GAIN_SIXTEEN = ADS1015_REG_CONFIG_PGA_0_256V
} adsGain_t;
class Adafruit_ADS1015
{
protected:
// Instance-specific properties
uint8_t m_i2cAddress;
uint8_t m_conversionDelay;
uint8_t m_bitShift;
adsGain_t m_gain;
public:
Adafruit_ADS1015(uint8_t i2cAddress = ADS1015_ADDRESS);
void begin(void);
uint16_t readADC_SingleEnded(uint8_t channel);
int16_t readADC_Differential_0_1(void);
int16_t readADC_Differential_2_3(void);
void startComparator_SingleEnded(uint8_t channel, int16_t threshold);
int16_t getLastConversionResults();
void setGain(adsGain_t gain);
adsGain_t getGain(void);
private:
};
// Derive from ADS1105 & override construction to set properties
class Adafruit_ADS1115 : public Adafruit_ADS1015
{
public:
Adafruit_ADS1115(uint8_t i2cAddress = ADS1015_ADDRESS);
private:
};

@ -0,0 +1,152 @@
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <MozziGuts.h>
#include <Oscil.h>
#include <tables/square_no_alias_2048_int8.h>
//#include <ReverbTank.h> /*Only required for reverb*/
//#include <SensorToButton.h>
//ReverbTank reverb;
//Multiplex adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
#define CONTROL_RATE 64 // powers of 2 please
Oscil<SQUARE_NO_ALIAS_2048_NUM_CELLS, AUDIO_RATE> tone_1(SQUARE_NO_ALIAS_2048_DATA);
Oscil<SQUARE_NO_ALIAS_2048_NUM_CELLS, AUDIO_RATE> tone_2(SQUARE_NO_ALIAS_2048_DATA);
Oscil<SQUARE_NO_ALIAS_2048_NUM_CELLS, AUDIO_RATE> tone_3(SQUARE_NO_ALIAS_2048_DATA);
int count= 0;
boolean note1 = false;
boolean note2 = false;
boolean note3 = false;
boolean codeswitch = false;
void setup(){
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
//start the multiplexing
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
startMozzi(CONTROL_RATE);
tone_1.setFreq(262);
tone_1.setPhase(120);
tone_2.setFreq(330);
tone_2.setPhase(240 );
tone_3.setFreq(392);
}
void updateControl(){
//Log number of notes playing
if (note1){
count++;
}
if (note2){
count++;
}
if (note3){
count++;
}
}
int updateAudio(){
int result = 0;
//Play notes and mix down (according to notes playing
if (note1) {
result += tone_1.next() * (1/count);
}
if (note2) {
result += tone_2.next() * (1/count);
}
if (note3) {
result += tone_3.next() * (1/count);
}
//int arev = reverb.next(result); /*Initialize reverb*/
//return result + (arev>>3); /*Reverb: Mix signal*/
//return arev; /*Reverb: Wet signal*/
//return result; /*Reverb: Dry signal*/
//if (!codeswitch){
//polysynth
return result;
//}
//else if (codeswitch) {
//controlvoltage
//return CV;
//}
}
void loop(){
//Messure LDR multiplex inputs
int16_t adc0a, adc1a, adc2a, adc3a, adc0b, adc1b, adc2b, adc3b, adc0c, adc1c, adc2c, adc3c, adc0d, adc1d, adc2d, adc3d;
adc0a = adsa.readADC_SingleEnded(0);
adc1a = adsa.readADC_SingleEnded(1);
adc2a = adsa.readADC_SingleEnded(2);
adc3a = adsa.readADC_SingleEnded(3);
// Serial.print("AIN0A: "); Serial.println(adc0a);
// Serial.print("AIN1A: "); Serial.println(adc1a);
// Serial.print("AIN2A: "); Serial.println(adc2a);
// Serial.print("AIN3A: "); Serial.println(adc3a);
// Serial.println(" ");
adc0b = adsb.readADC_SingleEnded(0);
adc1b = adsb.readADC_SingleEnded(1);
adc2b = adsb.readADC_SingleEnded(2);
adc3b = adsb.readADC_SingleEnded(3);
// Serial.print("AIN0B: "); Serial.println(adc0b);
// Serial.print("AIN1B: "); Serial.println(adc1b);
// Serial.print("AIN2B: "); Serial.println(adc2b);
// Serial.print("AIN3B: "); Serial.println(adc3b);
// Serial.println(" ");
adc0c = adsc.readADC_SingleEnded(0);
adc1c = adsc.readADC_SingleEnded(1);
adc2c = adsc.readADC_SingleEnded(2);
adc3c = adsc.readADC_SingleEnded(3);
// Serial.print("AIN0C: "); Serial.println(adc0c);
// Serial.print("AIN1C: "); Serial.println(adc1c);
// Serial.print("AIN2C: "); Serial.println(adc2c);
// Serial.print("AIN3C: "); Serial.println(adc3c);
// Serial.println(" ");
adc0d = adsd.readADC_SingleEnded(0);
adc1d = adsd.readADC_SingleEnded(1);
adc2d = adsd.readADC_SingleEnded(2);
adc3d = adsd.readADC_SingleEnded(3);
// Serial.print("AIN0D: "); Serial.println(adc0d);
// Serial.print("AIN1D: "); Serial.println(adc1d);
// Serial.print("AIN2D: "); Serial.println(adc2d);
// Serial.print("AIN3D: "); Serial.println(adc3d);
// Serial.println(" ");
// delay(1000);
audioHook();
//Switch between auditive output and CV out
// if (digitalRead (8) == LOW){
// codeswitch = false;
// }
// if (digitalRead (8) == HIGH){
// codeswitch = true;
// }
}

@ -0,0 +1,110 @@
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
#include <NoodleSynth.h>
#include <SensorToButton.h>
SensorToButton btn(2, 50); //pin, debounce time(ms)
synthEngine mixer(20E3);
#define NUM 8
MusicWithoutDelay instruments[NUM];
int vol = 0;
uint16_t INTERVAL = 15;
bool mode = true;
int flip = 1;
// int pins[6] = {CHA,CHB,6,9,22,23}; //for Teensy 3+
int pins[2] = {CHA,CHB};
//multiplex adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
int count= 0;
int TH;
int16_t adc0a, adc1a, adc2a, adc3a, adc0b, adc1b, adc2b, adc3b, adc0c, adc1c, adc2c, adc3c, adc0d, adc1d, adc2d, adc3d;
boolean codeswitch = false;
void setup(){
//set the gain for multiplexed ins
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
//start the multiplexing
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
for (byte i = 0; i < NUM; i++) {
MusicWithoutDelay *myInstrument = &instruments[i];
float freq = MusicWithoutDelay::getNoteAsFrequency(NOTE_A3 + i * 4); //Function gives Frequceny using a Formula. Every other 4 notes is a harmonic major(something like that)
myInstrument->begin(pins[i%2], SINE, ENVELOPE0, 0).setVolume(0).setFrequency(freq); //set up instruments and their frequencies
}
//set tone frequency and phase
// tone_1.setFreq(165);
// tone_1.setPhase(0);
// tone_2.setFreq(196);
// tone_2.setPhase(30);
// tone_3.setFreq(220);
// tone_3.setPhase(60);
// tone_4.setFreq(262);
// tone_4.setPhase(90);
// tone_5.setFreq(330);
// tone_5.setPhase(120);
// tone_6.setFreq(392);
// tone_6.setPhase(150);
// tone_7.setFreq(440);
// tone_7.setPhase(180);
// tone_8.setFreq(523);
// tone_8.setPhase(210);
// tone_9.setFreq(659);
// tone_9.setPhase(240);
// tone_10.setFreq(784);
// tone_10.setPhase(270);
// tone_11.setFreq(880);
// tone_11.setPhase(300);
// tone_12.setFreq(1047);
// tone_12.setPhase(330);
//calibrate (set treshold)
TH = adsb.readADC_SingleEnded(3);
}
uint32_t pMillis, serialMillis;
void loop(){
uint32_t cMillis = millis();
btn.read();
// if (cMillis - serialMillis > 500) {
for (byte i = 0; i < NUM; i++) {
MusicWithoutDelay *myInstrument = &instruments[i];
myInstrument->update().setVolume(vol); //update instruments
}
// serialMillis = cMillis;
// }
if (mode) {
vol = analogRead(potPin);
vol = map(vol, 0, 1023, 0, 127);
}
else {
if (cMillis - pMillis >= INTERVAL) { //Vibrato
vol += flip;
if (vol < 90 || vol > 126) {
flip *= -1;
}
pMillis = cMillis;
}
}
if (btn.wasPressed()) {
vol = 95;
mode = !mode;
}
}

@ -0,0 +1,194 @@
#include <MozziGuts.h>
#include <Oscil.h>
#include <tables/saw256_int8.h>
#include <Adafruit_ADS1015.h>
#include <Wire.h>
//#include <mozzi_fixmath.h>
//#include <utility/twi_nonblock.h>
#define CONTROL_RATE 128 // powers of 2 please
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_1(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_2(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_3(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_4(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_5(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_6(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_7(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_8(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_9(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_10(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_11(SAW256_DATA);
Oscil<SAW256_NUM_CELLS, AUDIO_RATE> tone_12(SAW256_DATA);
//multiplex adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
int count= 0;
int TH;
int16_t adc0a, adc1a, adc2a, adc3a, adc0b, adc1b, adc2b, adc3b, adc0c, adc1c, adc2c, adc3c, adc0d, adc1d, adc2d, adc3d;
boolean note1 = false;
boolean note2 = false;
boolean note3 = false;
boolean codeswitch = false;
void setup(){
//set the gain for multiplexed ins
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
//start the multiplexing
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
startMozzi(CONTROL_RATE);
//set tone frequency and phase
tone_1.setFreq(165);
tone_1.setPhase(0);
tone_2.setFreq(196);
tone_2.setPhase(30);
tone_3.setFreq(220);
tone_3.setPhase(60);
tone_4.setFreq(262);
tone_4.setPhase(90);
tone_5.setFreq(330);
tone_5.setPhase(120);
tone_6.setFreq(392);
tone_6.setPhase(150);
tone_7.setFreq(440);
tone_7.setPhase(180);
tone_8.setFreq(523);
tone_8.setPhase(210);
tone_9.setFreq(659);
tone_9.setPhase(240);
tone_10.setFreq(784);
tone_10.setPhase(270);
tone_11.setFreq(880);
tone_11.setPhase(300);
tone_12.setFreq(1047);
tone_12.setPhase(330);
//calibrate (set treshold)
TH = adsb.readADC_SingleEnded(3);
}
void updateControl(){
//log number of notes playing
if (adc0a < TH) {
count++;
}
if (adc1a < TH) {
count++;
}
if (adc2a < TH) {
count++;
}
if (adc3a < TH) {
count++;
}
if (adc0b < TH) {
count++;
}
if (adc1b < TH) {
count++;
}
if (adc2b < TH) {
count++;
}
if (adc3b < TH) {
count++;
}
if (adc0c < TH) {
count++;
}
if (adc1c < TH) {
count++;
}
if (adc2c < TH) {
count++;
}
if (adc3c < TH) {
count++;
}
}
int updateAudio(){
int result = 0;
//Play notes and mix down (according to notes playing
if (adc0a < TH) {
result += tone_1.next() * (1/count);
}
if (adc1a < TH) {
result += tone_2.next() * (1/count);
}
if (adc2a < TH) {
result += tone_3.next() * (1/count);
}
if (adc3a < TH) {
result += tone_4.next() * (1/count);
}
if (adc0b < TH) {
result += tone_5.next() * (1/count);
}
if (adc1b < TH) {
result += tone_6.next() * (1/count);
}
if (adc2b < TH) {
result += tone_7.next() * (1/count);
}
if (adc3b < TH) {
result += tone_8.next() * (1/count);
}
if (adc0c < TH) {
result += tone_9.next() * (1/count);
}
if (adc1c < TH) {
result += tone_10.next() * (1/count);
}
if (adc2c < TH) {
result += tone_11.next() * (1/count);
}
if (adc3c < TH) {
result += tone_12.next() * (1/count);
}
return result;
}
void loop(){
//Messure LDR multiplex inputs
adc0a = adsa.readADC_SingleEnded(0);
adc1a = adsa.readADC_SingleEnded(1);
adc2a = adsa.readADC_SingleEnded(2);
adc3a = adsa.readADC_SingleEnded(3);
adc0b = adsb.readADC_SingleEnded(0);
adc1b = adsb.readADC_SingleEnded(1);
adc2b = adsb.readADC_SingleEnded(2);
adc3b = adsb.readADC_SingleEnded(3);
adc0c = adsc.readADC_SingleEnded(0);
adc1c = adsc.readADC_SingleEnded(1);
adc2c = adsc.readADC_SingleEnded(2);
adc3c = adsc.readADC_SingleEnded(3);
adc0d = adsd.readADC_SingleEnded(0);
adc1d = adsd.readADC_SingleEnded(1);
adc2d = adsd.readADC_SingleEnded(2);
adc3d = adsd.readADC_SingleEnded(3);
audioHook();
}

@ -0,0 +1,713 @@
#include <MozziGuts.h>
#include <Oscil.h>
#include <tables/sin2048_int8.h>
#include <Line.h> // for envelope
#include <ADSR.h>
#include <mozzi_fixmath.h>
#include <ADC.h>
#include <IntervalTimer.h>
//#include <MusicWithoutDelay.h>
//#include <synth.h>
//#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
//const char note0[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
//const char note1[] PROGMEM = ":d=128,b=300:d-1+"; //plays d4
//const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
//const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
//const char note4[] PROGMEM = ":d=128,b=300:a-1+"; //plays a4
//const char note5[] PROGMEM = ":d=128,b=300:c+"; //plays c5
//const char note6[] PROGMEM = ":d=128,b=300:d+"; //plays d5
//const char note7[] PROGMEM = ":d=128,b=300:e+"; //plays e5
//const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
//const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
//const char note10[] PROGMEM = ":d=128,b=300:c+1+"; //plays c6
//const char note11[] PROGMEM = ":d=128,b=300:d+1+"; //plays d6
//const char note12[] PROGMEM = ":d=128,b=300:e+1+"; //plays e6
//const char note13[] PROGMEM = ":d=128,b=300:g+1+"; //plays g6
//const char note14[] PROGMEM = ":d=128,b=300:a+1+"; //plays a6
//const char note15[] PROGMEM = ":d=128,b=300:c+2+"; //plays c7
//instruments
//MusicWithoutDelay Insta(note0);
//MusicWithoutDelay Instb(note1);
//MusicWithoutDelay Instc(note2);
//MusicWithoutDelay Instd(note3);
//MusicWithoutDelay Inste(note4);
//MusicWithoutDelay Instf(note5);
//MusicWithoutDelay Instg(note6);
//MusicWithoutDelay Insth(note7);
//MusicWithoutDelay Insti(note8);
//MusicWithoutDelay Instj(note9);
//MusicWithoutDelay Instk(note10);
//MusicWithoutDelay Instl(note11);
//MusicWithoutDelay Instm(note12);
//MusicWithoutDelay Instn(note13);
//MusicWithoutDelay Insto(note14);
//MusicWithoutDelay Instp(note15);
#define CONTROL_RATE 64
#define ATTACK 50 // long enough for control rate to catch it
#define DECAY 50
#define SUSTAIN 600000 // Sustain 60 seconds unless a noteOff comes.
#define RELEASE 1000
#define ATTACK_LEVEL 255
#define DECAY_LEVEL 255
Oscil <2048, AUDIO_RATE> Insta(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instb(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instc(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instd(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Inste(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instf(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instg(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Insth(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Insti(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instj(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instk(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instl(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instm(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instn(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Insto(SIN2048_DATA);
Oscil <2048, AUDIO_RATE> Instp(SIN2048_DATA);
ADSR <CONTROL_RATE, CONTROL_RATE> envelope1;
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
bool ZER;
bool ONE;
bool TWO;
bool THR;
bool FOU;
bool FIV;
bool SIX;
bool SEV;
bool EIG;
bool NIN;
bool TEN;
bool ELE;
bool TWE;
bool THT;
bool FOT;
bool FIT;
void setup() {
Serial.begin(9600);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
Insta.setFreq(165);
Insta.setPhase(0);
Instb.setFreq(196);
Instb.setPhase(30);
Instc.setFreq(220);
Instc.setPhase(60);
Instd.setFreq(262);
Instd.setPhase(90);
Inste.setFreq(330);
Inste.setPhase(120);
Instf.setFreq(392);
Instf.setPhase(150);
Instg.setFreq(440);
Instg.setPhase(180);
Insth.setFreq(523);
Insth.setPhase(210);
Insti.setFreq(659);
Insti.setPhase(240);
Instj.setFreq(784);
Instj.setPhase(270);
Instk.setFreq(880);
Instk.setPhase(300);
Instl.setFreq(1047);
Instl.setPhase(330);
Instm.setFreq(659);
Instm.setPhase(240);
Instn.setFreq(784);
Instn.setPhase(270);
Insto.setFreq(880);
Insto.setPhase(300);
Instp.setFreq(1047);
Instp.setPhase(330);
envelope1.setADLevels(ATTACK_LEVEL,DECAY_LEVEL);
envelope1.setTimes(ATTACK,DECAY,SUSTAIN,RELEASE);
//
// Insta.begin(CHA, TRIANGLE, ENVELOPE2, 0);
// Instb.begin(TRIANGLE, ENVELOPE2, 0);
// Instc.begin(TRIANGLE, ENVELOPE2, 0);
// Instd.begin(TRIANGLE, ENVELOPE2, 0);
// Inste.begin(TRIANGLE, ENVELOPE2, 0);
// Instf.begin(TRIANGLE, ENVELOPE2, 0);
// Instg.begin(TRIANGLE, ENVELOPE2, 0);
// Insth.begin(TRIANGLE, ENVELOPE2, 0);
// Insti.begin(TRIANGLE, ENVELOPE2, 0);
// Instj.begin(TRIANGLE, ENVELOPE2, 0);
// Instk.begin(TRIANGLE, ENVELOPE2, 0);
// Instl.begin(TRIANGLE, ENVELOPE2, 0);
// Instm.begin(TRIANGLE, ENVELOPE2, 0);
// Instn.begin(TRIANGLE, ENVELOPE2, 0);
// Insto.begin(TRIANGLE, ENVELOPE2, 0);
// Instp.begin(TRIANGLE, ENVELOPE2, 0);
//
// Insta.pause(true);
// Instb.pause(true);
// Instc.pause(true);
// Instd.pause(true);
// Inste.pause(true);
// Instf.pause(true);
// Instg.pause(true);
// Insth.pause(true);
// Insti.pause(true);
// Instj.pause(true);
// Instk.pause(true);
// Instl.pause(true);
// Instm.pause(true);
// Instn.pause(true);
// Insto.pause(true);
// Instp.pause(true);
startMozzi(CONTROL_RATE);
Serial.println("go!");
}
void updateControl(){
if (VA0 > TH0) {
count++;
ZER = true;
if (CV) {
digitalWrite(0, HIGH);
}
else if (!CV) {
digitalWrite(0, LOW);
}
}
else if (VA0 < TH0) {
ZER = false;
//Kill ControlVoltage
digitalWrite(0, LOW);
}
if (VA1 > TH1) {
count++;
ONE = true;
if (CV) {
digitalWrite(1, HIGH);
}
else if (!CV) {
digitalWrite(1, LOW);
}
}
else if (VA1 < TH1) {
ONE = false;
//Kill ControlVoltage
digitalWrite(1, LOW);
}
if (VA2 > TH2) {
count++;
TWO = true;
if (CV) {
digitalWrite(2, HIGH);
}
else if (!CV) {
digitalWrite(2, LOW);
}
}
else if (VA2 < TH2) {
TWO = false;
//Kill ControlVoltage
digitalWrite(2, LOW);
}
if (VA3 > TH3) {
count++;
THR = true;
if (CV) {
digitalWrite(3, HIGH);
}
else if (!CV) {
digitalWrite(3, LOW);
}
}
else if (VA3 < TH3) {
THR = false;
//Kill ControlVoltage
digitalWrite(3, LOW);
}
if (VA4 > TH4) {
count++;
FOU = true;
if (CV) {
digitalWrite(4, HIGH);
}
else if (!CV) {
digitalWrite(4, LOW);
}
}
else if (VA4 < TH4) {
FOU = false;
//Kill ControlVoltage
digitalWrite(4, LOW);
}
if (VA5 > TH5) {
if (CV) {
digitalWrite(5, HIGH);
}
else if (!CV) {
digitalWrite(5, LOW);
}
count++;
FIV = true;
}
else if (VA5 < TH5) {
FIV = false;
//Kill ControlVoltage
digitalWrite(5, LOW);
}
if (VA6 > TH6) {
count++;
SIX = true;
if (CV) {
digitalWrite(6, HIGH);
}
else if (!CV) {
digitalWrite(6, LOW);
}
}
else if (VA6 < TH6) {
SIX = false;
//Kill ControlVoltage
digitalWrite(6, LOW);
}
if (VA7 > TH7) {
count++;
SEV = true;
if (CV) {
digitalWrite(7, HIGH);
}
else if (!CV) {
digitalWrite(7, LOW);
}
}
else if (VA7 < TH7) {
SEV = false;
//Kill ControlVoltage
digitalWrite(7, LOW);
}
if (VA8 > TH8) {
count++;
EIG = true;
if (CV) {
digitalWrite(8, HIGH);
}
else if (!CV) {
digitalWrite(8, LOW);
}
}
else if (VA8 < TH8) {
EIG = false;
//Kill ControlVoltage
digitalWrite(8, LOW);
}
if (VA9 > TH9) {
count++;
NIN = true;
if (CV) {
digitalWrite(9, HIGH);
}
else if (!CV) {
digitalWrite(9, LOW);
}
}
else if (VA9 < TH9) {
NIN = false;
//Kill ControlVoltage
digitalWrite(9, LOW);
}
if (VA10 > TH10) {
count++;
TEN = true;
if (CV) {
digitalWrite(10, HIGH);
}
else if (!CV) {
digitalWrite(10, LOW);
}
}
else if (VA10 < TH10) {
TEN = false;
//Kill ControlVoltage
digitalWrite(10, LOW);
}
if (VA11 > TH11) {
count++;
ELE = true;
if (CV) {
digitalWrite(11, HIGH);
}
else if (!CV) {
digitalWrite(11, LOW);
}
}
else if (VA11 < TH11) {
ELE = false;
//Kill ControlVoltage
digitalWrite(11, LOW);
}
if (VA12 > TH12) {
count++;
TWE = true;
if (CV) {
digitalWrite(12, HIGH);
}
else if (!CV) {
digitalWrite(12, LOW);
}
}
else if (VA12 < TH12) {
TWE = false;
//Kill ControlVoltage
digitalWrite(12, LOW);
}
if (VA13 > TH13) {
count++;
THT = true;
if (CV) {
digitalWrite(13, HIGH);
}
else if (!CV) {
digitalWrite(13, LOW);
}
}
else if (VA13 < TH13) {
THT = false;
//Kill ControlVoltage
digitalWrite(13, LOW);
}
if (VA14 > TH14) {
count++;
FOT = true;
if (CV) {
digitalWrite(14, HIGH);
}
else if (!CV) {
digitalWrite(14, LOW);
}
}
else if (VA14 < TH14) {
FOT = false;
//Kill ControlVoltage
digitalWrite(14, LOW);
}
if (VA15 > TH15) {
count++;
FIT = true;
if (CV) {
digitalWrite(15, HIGH);
}
else if (!CV) {
digitalWrite(15, LOW);
}
}
else if (VA15 < TH15) {
FIT = false;
//Kill ControlVoltage
digitalWrite(15, LOW);
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
}
int updateAudio(){
int result = 0;
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
//envelope1.update();
//return Insta.noteOn());
return (Insta) (envelope1.noteOn());
}
if (!ZER) {
envelope1.noteOff();
}
if (ONE) {
// VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
result += Instb.next();
}
if (!ONE) {
}
if (TWO) {
result += Instc.next();
}
if (!TWO) {
}
if (THR) {
result += Instd.next();
}
if (!THR) {
}
if (FOU) {
result += Inste.next();
}
if (!FOU) {
}
if (FIV) {
result += Instf.next();
}
if (!FIV) {
}
if (SIX) {
result += Instg.next();
}
if (!SIX) {
}
if (SEV) {
result += Insth.next();
}
if (!SEV) {
}
if (EIG) {
result += Insti.next();
}
if (!EIG) {
}
if (NIN) {
result += Instj.next();
}
if (!NIN) {
}
if (TEN) {
result += Instk.next();
}
if (!TEN) {
}
if (ELE) {
result += Instl.next();
}
if (!ELE) {
}
if (TWE) {
result += Instm.next();
}
if (!TWE) {
}
if (THT) {
result += Instn.next();
}
if (!THT) {
}
if (FOT) {
result += Insto.next();
}
if (!FOT) {
}
if (FIT) {
result += Instp.next();
}
if (!FIT) {
}
return;
}
void loop() {
CV = digitalRead(22);
count = 0;
// Insta.update();
// Instb.update();
// Instc.update();
// Instd.update();
// Inste.update();
// Instf.update();
// Instg.update();
// Insth.update();
// Insti.update();
// Instj.update();
// Instk.update();
// Instl.update();
// Instm.update();
// Instn.update();
// Insto.update();
// Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
audioHook();
}

@ -0,0 +1,773 @@
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=300:d-1+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:a-1+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:c+1+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=300:d+1+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=300:e+1+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=300:g+1+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=300:a+1+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=300:c+2+"; //plays c7
//instruments
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
bool ZER;
bool ONE;
bool TWO;
bool THR;
bool FOU;
bool FIV;
bool SIX;
bool SEV;
bool EIG;
bool NIN;
bool TEN;
bool ELE;
bool TWE;
bool THT;
bool FOT;
bool FIT;
void setup() {
Serial.begin(115200);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
Insta.begin(CHA, TRIANGLE, ENVELOPE0, 0);
Instb.begin(TRIANGLE, ENVELOPE0, 0);
Instc.begin(TRIANGLE, ENVELOPE0, 0);
Instd.begin(TRIANGLE, ENVELOPE0, 0);
Inste.begin(TRIANGLE, ENVELOPE0, 0);
Instf.begin(TRIANGLE, ENVELOPE0, 0);
Instg.begin(TRIANGLE, ENVELOPE0, 0);
Insth.begin(TRIANGLE, ENVELOPE0, 0);
Insti.begin(TRIANGLE, ENVELOPE0, 0);
Instj.begin(TRIANGLE, ENVELOPE0, 0);
Instk.begin(TRIANGLE, ENVELOPE0, 0);
Instl.begin(TRIANGLE, ENVELOPE0, 0);
Instm.begin(TRIANGLE, ENVELOPE0, 0);
Instn.begin(TRIANGLE, ENVELOPE0, 0);
Insto.begin(TRIANGLE, ENVELOPE0, 0);
Instp.begin(TRIANGLE, ENVELOPE0, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void loop() {
CV = digitalRead(22);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (VA0 > TH0) {
count++;
ZER = true;
}
else if (VA0 < TH0) {
ZER = false;
}
if (VA1 > TH1) {
count++;
ONE = true;
}
else if (VA1 < TH1) {
ONE = false;
}
if (VA2 > TH2) {
count++;
TWO = true;
}
else if (VA2 < TH2) {
TWO = false;
}
if (VA3 > TH3) {
count++;
THR = true;
}
else if (VA3 < TH3) {
THR = false;
}
if (VA4 > TH4) {
count++;
FOU = true;
}
else if (VA4 < TH4) {
FOU = false;
}
if (VA5 > TH5) {
count++;
FIV = true;
}
else if (VA5 < TH5) {
FIV = false;
}
if (VA6 > TH6) {
count++;
SIX = true;
}
else if (VA6 < TH6) {
SIX = false;
}
if (VA7 > TH7) {
count++;
SEV = true;
}
else if (VA7 < TH7) {
SEV = false;
}
if (VA8 > TH8) {
count++;
EIG = true;
}
else if (VA8 < TH8) {
EIG = false;
}
if (VA9 > TH9) {
count++;
NIN = true;
}
else if (VA9 < TH9) {
NIN = false;
}
if (VA10 > TH10) {
count++;
TEN = true;
}
else if (VA10 < TH10) {
TEN = false;
}
if (VA11 > TH11) {
count++;
ELE = true;
}
else if (VA11 < TH11) {
ELE = false;
}
if (VA12 > TH12) {
count++;
TWE = true;
}
else if (VA12 < TH12) {
TWE = false;
}
if (VA13 > TH13) {
count++;
THT = true;
}
else if (VA13 < TH13) {
THT = false;
}
if (VA14 > TH14) {
count++;
FOT = true;
}
else if (VA14 < TH14) {
FOT = false;
}
if (VA15 > TH15) {
count++;
FIT = true;
}
else if (VA15 < TH15) {
FIT = false;
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(0, HIGH);
}
else if (!CV) {
digitalWrite(0, LOW);
}
}
if (!ZER) {
Insta.pause (true);
//Kill ControlVoltage
digitalWrite(0, LOW);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(1, HIGH);
}
else if (!CV) {
digitalWrite(1, LOW);
}
}
if (!ONE) {
Instb.pause (true);
//Kill ControlVoltage
digitalWrite(1, LOW);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(2, HIGH);
}
else if (!CV) {
digitalWrite(2, LOW);
}
}
if (!TWO) {
Instc.pause (true);
//Kill ControlVoltage
digitalWrite(2, LOW);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(3, HIGH);
}
else if (!CV) {
digitalWrite(3, LOW);
}
}
if (!THR) {
Instd.pause (true);
//Kill ControlVoltage
digitalWrite(3, LOW);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(4, HIGH);
}
else if (!CV) {
digitalWrite(4, LOW);
}
}
if (!FOU) {
Inste.pause (true);
//Kill ControlVoltage
digitalWrite(4, LOW);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(5, HIGH);
}
else if (!CV) {
digitalWrite(5, LOW);
}
}
if (!FIV) {
Instf.pause (true);
//Kill ControlVoltage
digitalWrite(5, LOW);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(6, HIGH);
}
else if (!CV) {
digitalWrite(6, LOW);
}
}
if (!SIX) {
Instg.pause (true);
//Kill ControlVoltage
digitalWrite(6, LOW);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(7, HIGH);
}
else if (!CV) {
digitalWrite(7, LOW);
}
}
if (!SEV) {
Insth.pause (true);
//Kill ControlVoltage
digitalWrite(7, LOW);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(8, HIGH);
}
else if (!CV) {
digitalWrite(8, LOW);
}
}
if (!EIG) {
Insti.pause (true);
//Kill ControlVoltage
digitalWrite(8, LOW);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(9, HIGH);
}
else if (!CV) {
digitalWrite(9, LOW);
}
}
if (!NIN) {
Instk.pause (true);
//Kill ControlVoltage
digitalWrite(9, LOW);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(10, HIGH);
}
else if (!CV) {
digitalWrite(10, LOW);
}
}
if (!TEN) {
Instk.pause (true);
//Kill ControlVoltage
digitalWrite(10, LOW);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(11, HIGH);
}
else if (!CV) {
digitalWrite(11, LOW);
}
}
if (!ELE) {
Instl.pause (true);
//Kill ControlVoltage
digitalWrite(11, LOW);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(12, HIGH);
}
else if (!CV) {
digitalWrite(12, LOW);
}
}
if (!TWE) {
Instm.pause (true);
//Kill ControlVoltage
digitalWrite(12, LOW);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(13, HIGH);
}
else if (!CV) {
digitalWrite(13, LOW);
}
}
if (!THT) {
Instn.pause (true);
//Kill ControlVoltage
digitalWrite(13, LOW);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(14, HIGH);
}
else if (!CV) {
digitalWrite(14, LOW);
}
}
if (!FOT) {
Insto.pause (true);
//Kill ControlVoltage
digitalWrite(14, LOW);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(15, HIGH);
}
else if (!CV) {
digitalWrite(15, LOW);
}
}
if (!FIT) {
Instp.pause (true);
//Kill ControlVoltage
digitalWrite(15, LOW);
}
}

@ -0,0 +1,747 @@
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=300:d-1+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:a-1+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:c+1+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=300:d+1+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=300:e+1+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=300:g+1+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=300:a+1+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=300:c+2+"; //plays c7
//instruments
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
int ZER;
int ONE;
int TWO;
int THR;
int FOU;
int FIV;
int SIX;
int SEV;
int EIG;
int NIN;
int TEN;
int ELE;
int TWE;
int THT;
int FOT;
int FIT;
void setup() {
Serial.begin(115200);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
calib();
Insta.begin(CHA, TRIANGLE, ENVELOPE2, 0);
Instb.begin(TRIANGLE, ENVELOPE2, 0);
Instc.begin(TRIANGLE, ENVELOPE2, 0);
Instd.begin(TRIANGLE, ENVELOPE2, 0);
Inste.begin(TRIANGLE, ENVELOPE2, 0);
Instf.begin(TRIANGLE, ENVELOPE2, 0);
Instg.begin(TRIANGLE, ENVELOPE2, 0);
Insth.begin(TRIANGLE, ENVELOPE2, 0);
Insti.begin(TRIANGLE, ENVELOPE2, 0);
Instj.begin(TRIANGLE, ENVELOPE2, 0);
Instk.begin(TRIANGLE, ENVELOPE2, 0);
Instl.begin(TRIANGLE, ENVELOPE2, 0);
Instm.begin(TRIANGLE, ENVELOPE2, 0);
Instn.begin(TRIANGLE, ENVELOPE2, 0);
Insto.begin(TRIANGLE, ENVELOPE2, 0);
Instp.begin(TRIANGLE, ENVELOPE2, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void calib() {
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
}
void loop() {
CV = digitalRead(17);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (VA0 > TH0) {
count++;
ZER = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(0, HIGH);
}
else if (!CV) {
digitalWrite(0, LOW);
}
}
else if (VA0 < TH0) {
ZER = false;
//Kill ControlVoltage
digitalWrite(0, LOW);
}
if (VA1 > TH1) {
count++;
ONE = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(1, HIGH);
}
else if (!CV) {
digitalWrite(1, LOW);
}
}
else if (VA1 < TH1) {
ONE = false;
//Kill ControlVoltage
digitalWrite(1, LOW);
}
if (VA2 > TH2) {
count++;
TWO = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(2, HIGH);
}
else if (!CV) {
digitalWrite(2, LOW);
}
}
else if (VA2 < TH2) {
TWO = false;
//Kill ControlVoltage
digitalWrite(2, LOW);
}
if (VA3 > TH3) {
count++;
THR = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(4, HIGH);
}
else if (!CV) {
digitalWrite(4, LOW);
}
}
else if (VA3 < TH3) {
THR = false;
//Kill ControlVoltage
digitalWrite(4, LOW);
}
if (VA4 > TH4) {
count++;
FOU = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(5, HIGH);
}
else if (!CV) {
digitalWrite(5, LOW);
}
}
else if (VA4 < TH4) {
FOU = false;
//Kill ControlVoltage
digitalWrite(5, LOW);
}
if (VA5 > TH5) {
count++;
FIV = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(6, HIGH);
}
else if (!CV) {
digitalWrite(6, LOW);
}
}
else if (VA5 < TH5) {
FIV = false;
//Kill ControlVoltage
digitalWrite(6, LOW);
}
if (VA6 > TH6) {
count++;
SIX = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(7, HIGH);
}
else if (!CV) {
digitalWrite(7, LOW);
}
}
else if (VA6 < TH6) {
SIX = false;
//Kill ControlVoltage
digitalWrite(7, LOW);
}
if (VA7 > TH7) {
count++;
SEV = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(8, HIGH);
}
else if (!CV) {
digitalWrite(8, LOW);
}
}
else if (VA7 < TH7) {
SEV = false;
//Kill ControlVoltage
digitalWrite(8, LOW);
}
if (VA8 > TH8) {
count++;
EIG = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(9, HIGH);
}
else if (!CV) {
digitalWrite(9, LOW);
}
}
else if (VA8 < TH8) {
EIG = false;
//Kill ControlVoltage
digitalWrite(9, LOW);
}
if (VA9 > TH9) {
count++;
NIN = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(10, HIGH);
}
else if (!CV) {
digitalWrite(10, LOW);
}
}
else if (VA9 < TH9) {
NIN = false;
//Kill ControlVoltage
digitalWrite(10, LOW);
}
if (VA10 > TH10) {
count++;
TEN = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(11, HIGH);
}
else if (!CV) {
digitalWrite(11, LOW);
}
}
else if (VA10 < TH10) {
TEN = false;
//Kill ControlVoltage
digitalWrite(11, LOW);
}
if (VA11 > TH11) {
count++;
ELE = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(12, HIGH);
}
else if (!CV) {
digitalWrite(12, LOW);
}
}
else if (VA11 < TH11) {
ELE = false;
//Kill ControlVoltage
digitalWrite(12, LOW);
}
if (VA12 > TH12) {
count++;
TWE = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(13, HIGH);
}
else if (!CV) {
digitalWrite(13, LOW);
}
}
else if (VA12 < TH12) {
TWE = false;
//Kill ControlVoltage
digitalWrite(13, LOW);
}
if (VA13 > TH13) {
count++;
THT = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(14, HIGH);
}
else if (!CV) {
digitalWrite(14, LOW);
}
}
else if (VA13 < TH13) {
THT = false;
//Kill ControlVoltage
digitalWrite(14, LOW);
}
if (VA14 > TH14) {
count++;
FOT = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(15, HIGH);
}
else if (!CV) {
digitalWrite(15, LOW);
}
}
else if (VA14 < TH14) {
FOT = false;
//Kill ControlVoltage
digitalWrite(15, LOW);
}
if (VA15 > TH15) {
count++;
FIT = true;
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(16, HIGH);
}
else if (!CV) {
digitalWrite(16, LOW);
}
}
else if (VA15 < TH15) {
FIT = false;
//Kill ControlVoltage
digitalWrite(16, LOW);
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
}
if (!ZER) {
Insta.pause (true);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
}
if (!ONE) {
Instb.pause (true);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
}
if (!TWO) {
Instc.pause (true);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
}
if (!THR) {
Instd.pause (true);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
}
if (!FOU) {
Inste.pause (true);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
}
if (!FIV) {
Instf.pause (true);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
}
if (!SIX) {
Instg.pause (true);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
}
if (!SEV) {
Insth.pause (true);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
}
if (!EIG) {
Insti.pause (true);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
}
if (!NIN) {
Instk.pause (true);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
}
if (!TEN) {
Instk.pause (true);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
}
if (!ELE) {
Instl.pause (true);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
}
if (!TWE) {
Instm.pause (true);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
}
if (!THT) {
Instn.pause (true);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
}
if (!FOT) {
Insto.pause (true);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
}
if (!FIT) {
Instp.pause (true);
}
}

@ -0,0 +1,766 @@
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=300:d-1+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:a-1+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:c+1+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=300:d+1+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=300:e+1+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=300:g+1+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=300:a+1+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=300:c+2+"; //plays c7
//instruments
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
int ZER;
int ONE;
int TWO;
int THR;
int FOU;
int FIV;
int SIX;
int SEV;
int EIG;
int NIN;
int TEN;
int ELE;
int TWE;
int THT;
int FOT;
int FIT;
void setup() {
Serial.begin(115200);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
calib();
Insta.begin(CHA, TRIANGLE, ENVELOPE2, 0);
Instb.begin(TRIANGLE, ENVELOPE2, 0);
Instc.begin(TRIANGLE, ENVELOPE2, 0);
Instd.begin(TRIANGLE, ENVELOPE2, 0);
Inste.begin(TRIANGLE, ENVELOPE2, 0);
Instf.begin(TRIANGLE, ENVELOPE2, 0);
Instg.begin(TRIANGLE, ENVELOPE2, 0);
Insth.begin(TRIANGLE, ENVELOPE2, 0);
Insti.begin(TRIANGLE, ENVELOPE2, 0);
Instj.begin(TRIANGLE, ENVELOPE2, 0);
Instk.begin(TRIANGLE, ENVELOPE2, 0);
Instl.begin(TRIANGLE, ENVELOPE2, 0);
Instm.begin(TRIANGLE, ENVELOPE2, 0);
Instn.begin(TRIANGLE, ENVELOPE2, 0);
Insto.begin(TRIANGLE, ENVELOPE2, 0);
Instp.begin(TRIANGLE, ENVELOPE2, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void calib() {
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
}
void loop() {
CV = digitalRead(20);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (VA0 > TH0 && !CV) {
count++;
ZER = true;
digitalWrite(0, LOW);
}
else if (VA0 > TH0 && CV) {
ZER = false;
digitalWrite(0, HIGH);
}
else if (VA0 < TH0) {
ZER = false;
digitalWrite(0, LOW);
}
if (VA1 > TH1 && !CV) {
count++;
ONE = true;
digitalWrite(1, LOW);
}
else if (VA1 > TH1 && CV) {
digitalWrite(1, HIGH);
ONE = false;
}
else if (VA1 < TH1) {
ONE = false;
digitalWrite(1, LOW);
}
if (VA2 > TH2 && !CV) {
count++;
TWO = true;
digitalWrite(2, LOW);
}
else if (VA2 > TH2 && CV) {
TWO = false;
digitalWrite(2, HIGH);
}
else if (VA2 < TH2) {
TWO = false;
digitalWrite(2, LOW);
}
if (VA3 > TH3 && !CV) {
count++;
THR = true;
digitalWrite(4, LOW);
}
else if (VA3 > TH3 && CV) {
THR = false;
digitalWrite(4, HIGH);
}
else if (VA3 < TH3) {
THR = false;
digitalWrite(4, LOW);
}
if (VA4 > TH4 && !CV) {
count++;
FOU = true;
digitalWrite(5, LOW);
}
else if (VA4 > TH4 && CV) {
FOU = false;
digitalWrite(5, HIGH);
}
else if (VA4 < TH4) {
FOU = false;
digitalWrite(5, LOW);
}
if (VA5 > TH5 && !CV) {
count++;
FIV = true;
digitalWrite(6, LOW);
}
else if (VA5 > TH5 && CV) {
FIV = false;
digitalWrite(6, HIGH);
}
else if (VA5 < TH5) {
FIV = false;
digitalWrite(6, LOW);
}
if (VA6 > TH6 && !CV) {
count++;
SIX = true;
digitalWrite(7, LOW);
}
else if (VA6 > TH6 && CV) {
SIX = false;
digitalWrite(7, HIGH);
}
else if (VA6 < TH6) {
SIX = false;
digitalWrite(7, LOW);
}
if (VA7 > TH7 && !CV) {
count++;
SEV = true;
digitalWrite(8, LOW);
}
else if (VA7 > TH7 && CV) {
SEV = false;
digitalWrite(8, HIGH);
}
else if (VA7 < TH7) {
SEV = false;
digitalWrite(8, LOW);
}
if (VA8 > TH8 && !CV) {
count++;
EIG = true;
digitalWrite(9, LOW);
}
else if (VA8 > TH8 && CV) {
EIG = false;
digitalWrite(9, HIGH);
}
else if (VA8 < TH8) {
EIG = false;
digitalWrite(9, LOW);
}
if (VA9 > TH9 && !CV) {
count++;
NIN = true;
digitalWrite(10, LOW);
}
else if (VA9 > TH9 && CV) {
NIN = false;
digitalWrite(10, HIGH);
}
else if (VA9 < TH9) {
NIN = false;
digitalWrite(10, LOW);
}
if (VA10 > TH10 && !CV) {
count++;
TEN = true;
digitalWrite(11, LOW);
}
else if (VA10 > TH10 && CV) {
TEN = false;
digitalWrite(11, HIGH);
}
else if (VA10 < TH10) {
TEN = false;
digitalWrite(11, LOW);
}
if (VA11 > TH11 && !CV) {
count++;
ELE = true;
digitalWrite(12, LOW);
}
else if (VA11 > TH11 && CV) {
ELE = false;
digitalWrite(12, HIGH);
}
else if (VA11 < TH11) {
ELE = false;
digitalWrite(12, LOW);
}
if (VA12 > TH12 && !CV) {
count++;
TWE = true;
digitalWrite(13, LOW);
}
else if (VA12 > TH12 && CV) {
TWE = false;
digitalWrite(13, HIGH);
}
else if (VA12 < TH12) {
TWE = false;
digitalWrite(13, LOW);
}
if (VA13 > TH13 && !CV) {
count++;
THT = true;
digitalWrite(14, LOW);
}
else if (VA13 > TH13 && CV) {
THT = false;
digitalWrite(14, HIGH);
}
else if (VA13 < TH13) {
THT = false;
digitalWrite(14, LOW);
}
if (VA14 > TH14 && !CV) {
count++;
FOT = true;
digitalWrite(15, LOW);
}
else if (VA14 > TH14 && CV) {
FOT = false;
digitalWrite(15, HIGH);
}
else if (VA14 < TH14) {
FOT = false;
digitalWrite(15, LOW);
}
if (VA15 > TH15 && !CV) {
count++;
FIT = true;
digitalWrite(16, LOW);
}
else if (VA15 > TH15 && CV) {
FIT = false;
digitalWrite(16, HIGH);
}
else if (VA15 < TH15) {
FIT = false;
digitalWrite(16, LOW);
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
}
if (!ZER) {
Insta.pause (true);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
}
if (!ONE) {
Instb.pause (true);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
}
if (!TWO) {
Instc.pause (true);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
}
if (!THR) {
Instd.pause (true);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
}
if (!FOU) {
Inste.pause (true);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
}
if (!FIV) {
Instf.pause (true);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
}
if (!SIX) {
Instg.pause (true);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
}
if (!SEV) {
Insth.pause (true);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
}
if (!EIG) {
Insti.pause (true);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
}
if (!NIN) {
Instk.pause (true);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
}
if (!TEN) {
Instk.pause (true);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
}
if (!ELE) {
Instl.pause (true);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
}
if (!TWE) {
Instm.pause (true);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
}
if (!THT) {
Instn.pause (true);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
}
if (!FOT) {
Insto.pause (true);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
}
if (!FIT) {
Instp.pause (true);
}
if (digitalRead(17) == HIGH) {
calib();
}
}

@ -0,0 +1,776 @@
#include <MusicWithoutDelay.h>
#include <synth.h>
#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=300:c-1+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=300:d-1+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=300:e-1+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=300:g-1+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=300:a-1+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=300:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=300:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=300:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=300:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=300:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=300:c+1+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=300:d+1+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=300:e+1+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=300:g+1+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=300:a+1+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=300:c+2+"; //plays c7
//instruments
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
bool ZER;
bool ONE;
bool TWO;
bool THR;
bool FOU;
bool FIV;
bool SIX;
bool SEV;
bool EIG;
bool NIN;
bool TEN;
bool ELE;
bool TWE;
bool THT;
bool FOT;
bool FIT;
void setup() {
Serial.begin(115200);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
Insta.begin(CHA, TRIANGLE, ENVELOPE2, 0);
Instb.begin(TRIANGLE, ENVELOPE2, 0);
Instc.begin(TRIANGLE, ENVELOPE2, 0);
Instd.begin(TRIANGLE, ENVELOPE2, 0);
Inste.begin(TRIANGLE, ENVELOPE2, 0);
Instf.begin(TRIANGLE, ENVELOPE2, 0);
Instg.begin(TRIANGLE, ENVELOPE2, 0);
Insth.begin(TRIANGLE, ENVELOPE2, 0);
Insti.begin(TRIANGLE, ENVELOPE2, 0);
Instj.begin(TRIANGLE, ENVELOPE2, 0);
Instk.begin(TRIANGLE, ENVELOPE2, 0);
Instl.begin(TRIANGLE, ENVELOPE2, 0);
Instm.begin(TRIANGLE, ENVELOPE2, 0);
Instn.begin(TRIANGLE, ENVELOPE2, 0);
Insto.begin(TRIANGLE, ENVELOPE2, 0);
Instp.begin(TRIANGLE, ENVELOPE2, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void loop() {
CV = digitalRead(22);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (VA0 > TH0) {
count++;
ZER = true;
}
else if (VA0 < TH0) {
ZER = false;
}
if (VA1 > TH1) {
count++;
ONE = true;
}
else if (VA1 < TH1) {
ONE = false;
}
if (VA2 > TH2) {
count++;
TWO = true;
}
else if (VA2 < TH2) {
TWO = false;
}
if (VA3 > TH3) {
count++;
THR = true;
}
else if (VA3 < TH3) {
THR = false;
}
if (VA4 > TH4) {
count++;
FOU = true;
}
else if (VA4 < TH4) {
FOU = false;
}
if (VA5 > TH5) {
count++;
FIV = true;
}
else if (VA5 < TH5) {
FIV = false;
}
if (VA6 > TH6) {
count++;
SIX = true;
}
else if (VA6 < TH6) {
SIX = false;
}
if (VA7 > TH7) {
count++;
SEV = true;
}
else if (VA7 < TH7) {
SEV = false;
}
if (VA8 > TH8) {
count++;
EIG = true;
}
else if (VA8 < TH8) {
EIG = false;
}
if (VA9 > TH9) {
count++;
NIN = true;
}
else if (VA9 < TH9) {
NIN = false;
}
if (VA10 > TH10) {
count++;
TEN = true;
}
else if (VA10 < TH10) {
TEN = false;
}
if (VA11 > TH11) {
count++;
ELE = true;
}
else if (VA11 < TH11) {
ELE = false;
}
if (VA12 > TH12) {
count++;
TWE = true;
}
else if (VA12 < TH12) {
TWE = false;
}
if (VA13 > TH13) {
count++;
THT = true;
}
else if (VA13 < TH13) {
THT = false;
}
if (VA14 > TH14) {
count++;
FOT = true;
}
else if (VA14 < TH14) {
FOT = false;
}
if (VA15 > TH15) {
count++;
FIT = true;
}
else if (VA15 < TH15) {
FIT = false;
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(0, HIGH);
}
else if (!CV) {
digitalWrite(0, LOW);
}
}
if (!ZER) {
Insta.pause (true);
//Kill ControlVoltage
digitalWrite(0, LOW);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(1, HIGH);
}
else if (!CV) {
digitalWrite(1, LOW);
}
}
if (!ONE) {
Instb.pause (true);
//Kill ControlVoltage
digitalWrite(1, LOW);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(2, HIGH);
}
else if (!CV) {
digitalWrite(2, LOW);
}
}
if (!TWO) {
Instc.pause (true);
//Kill ControlVoltage
digitalWrite(2, LOW);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(3, HIGH);
}
else if (!CV) {
digitalWrite(3, LOW);
}
}
if (!THR) {
Instd.pause (true);
//Kill ControlVoltage
digitalWrite(3, LOW);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(4, HIGH);
}
else if (!CV) {
digitalWrite(4, LOW);
}
}
if (!FOU) {
Inste.pause (true);
//Kill ControlVoltage
digitalWrite(4, LOW);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(5, HIGH);
}
else if (!CV) {
digitalWrite(5, LOW);
}
}
if (!FIV) {
Instf.pause (true);
//Kill ControlVoltage
digitalWrite(5, LOW);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(6, HIGH);
}
else if (!CV) {
digitalWrite(6, LOW);
}
}
if (!SIX) {
Instg.pause (true);
//Kill ControlVoltage
digitalWrite(6, LOW);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(7, HIGH);
}
else if (!CV) {
digitalWrite(7, LOW);
}
}
if (!SEV) {
Insth.pause (true);
//Kill ControlVoltage
digitalWrite(7, LOW);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(8, HIGH);
}
else if (!CV) {
digitalWrite(8, LOW);
}
}
if (!EIG) {
Insti.pause (true);
//Kill ControlVoltage
digitalWrite(8, LOW);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(9, HIGH);
}
else if (!CV) {
digitalWrite(9, LOW);
}
}
if (!NIN) {
Instk.pause (true);
//Kill ControlVoltage
digitalWrite(9, LOW);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(10, HIGH);
}
else if (!CV) {
digitalWrite(10, LOW);
}
}
if (!TEN) {
Instk.pause (true);
//Kill ControlVoltage
digitalWrite(10, LOW);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(11, HIGH);
}
else if (!CV) {
digitalWrite(11, LOW);
}
}
if (!ELE) {
Instl.pause (true);
//Kill ControlVoltage
digitalWrite(11, LOW);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(12, HIGH);
}
else if (!CV) {
digitalWrite(12, LOW);
}
}
if (!TWE) {
Instm.pause (true);
//Kill ControlVoltage
digitalWrite(12, LOW);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(13, HIGH);
}
else if (!CV) {
digitalWrite(13, LOW);
}
}
if (!THT) {
Instn.pause (true);
//Kill ControlVoltage
digitalWrite(13, LOW);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(14, HIGH);
}
else if (!CV) {
digitalWrite(14, LOW);
}
}
if (!FOT) {
Insto.pause (true);
//Kill ControlVoltage
digitalWrite(14, LOW);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
//Output ControlVoltage if switch is activated
if (CV) {
digitalWrite(15, HIGH);
}
else if (!CV) {
digitalWrite(15, LOW);
}
}
if (!FIT) {
Instp.pause (true);
//Kill ControlVoltage
digitalWrite(15, LOW);
}
}

@ -0,0 +1,680 @@
#include <MusicWithoutDelay.h>
//#include <synth.h>
//#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=600,o=3:c+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=600,o=3:d+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=600,o=3:e+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=600,o=3:g+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=600,o=3:a+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=600,o=4:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=600,o=4:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=600,o=4:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=600,o=4:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=600,o=4:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=600,o=5:c+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=600,o=5:d+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=600,o=5:e+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=600,o=5:g+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=600,o=5:a+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=600,o=6:c+"; //plays c7
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
int ZER;
int ONE;
int TWO;
int THR;
int FOU;
int FIV;
int SIX;
int SEV;
int EIG;
int NIN;
int TEN;
int ELE;
int TWE;
int THT;
int FOT;
int FIT;
void setup() {
Serial.begin(115200);
pinMode(20, INPUT);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
calib();
Insta.begin(CHA, TRIANGLE, ENVELOPE0, 0);
Instb.begin(TRIANGLE, ENVELOPE0, 0);
Instc.begin(TRIANGLE, ENVELOPE0, 0);
Instd.begin(TRIANGLE, ENVELOPE0, 0);
Inste.begin(TRIANGLE, ENVELOPE0, 0);
Instf.begin(TRIANGLE, ENVELOPE0, 0);
Instg.begin(TRIANGLE, ENVELOPE0, 0);
Insth.begin(TRIANGLE, ENVELOPE0, 0);
Insti.begin(TRIANGLE, ENVELOPE0, 0);
Instj.begin(TRIANGLE, ENVELOPE0, 0);
Instk.begin(TRIANGLE, ENVELOPE0, 0);
Instl.begin(TRIANGLE, ENVELOPE0, 0);
Instm.begin(TRIANGLE, ENVELOPE0, 0);
Instn.begin(TRIANGLE, ENVELOPE0, 0);
Insto.begin(TRIANGLE, ENVELOPE0, 0);
Instp.begin(TRIANGLE, ENVELOPE0, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void calib() {
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
}
void loop() {
bool curcv = digitalRead(20);
// Serial.println (curcv);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (CV != curcv) {
CV = curcv;
// CV changes
// Serial.print("cv");
// Serial.println(CV);
if (CV) {
// entering Audio
Serial.println("entering Audio");
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
digitalWrite(15, LOW);
digitalWrite(16, LOW);
} else {
//entering CV
Serial.println("entering CV");
ZER = false;
ONE = false;
TWO = false;
THR = false;
FOU = false;
FIV = false;
SIX = false;
SEV = false;
EIG = false;
NIN = false;
TEN = false;
ELE = false;
TWE = false;
THT = false;
FOT = false;
FIT = false;
}
}
if (!CV) {
control();
} else {
audio();
}
//if (digitalRead(17) == LOW) {
//calib();
//}
}
void control() {
if (VA0 > TH0) {
digitalWrite(0, HIGH);
}
else if (VA0 < TH0) {
digitalWrite(0, LOW);
}
if (VA1 > TH1) {
digitalWrite(1, HIGH);
}
else if (VA1 < TH1) {
digitalWrite(1, LOW);
}
if (VA2 > TH2) {
digitalWrite(2, HIGH);
}
else if (VA2 < TH2) {
digitalWrite(2, LOW);
}
if (VA3 > TH3) {
digitalWrite(4, HIGH);
}
else if (VA3 < TH3) {
digitalWrite(4, LOW);
}
if (VA4 > TH4) {
digitalWrite(5, HIGH);
}
else if (VA4 < TH4) {
digitalWrite(5, LOW);
}
if (VA5 > TH5) {
digitalWrite(7, HIGH);
}
else if (VA5 < TH5) {
digitalWrite(7, LOW);
}
if (VA6 > TH6) {
digitalWrite(6, HIGH);
}
else if (VA6 < TH6) {
digitalWrite(6, LOW);
}
if (VA7 > TH7) {
digitalWrite(8, HIGH);
}
else if (VA7 < TH7) {
digitalWrite(8, LOW);
}
if (VA8 > TH8) {
digitalWrite(9, HIGH);
}
else if (VA8 < TH8) {
digitalWrite(9, LOW);
}
if (VA9 > TH9) {
digitalWrite(10, HIGH);
}
else if (VA9 < TH9) {
digitalWrite(10, LOW);
}
if (VA10 > TH10) {
digitalWrite(12, HIGH);
}
else if (VA10 < TH10) {
digitalWrite(12, LOW);
}
if (VA11 > TH11) {
digitalWrite(11, HIGH);
}
else if (VA11 < TH11) {
digitalWrite(11, LOW);
}
if (VA12 > TH12) {
digitalWrite(13, HIGH);
}
else if (VA12 < TH12) {
digitalWrite(13, LOW);
}
if (VA13 > TH13) {
digitalWrite(14, HIGH);
}
else if (VA13 < TH13) {
digitalWrite(14, LOW);
}
if (VA14 > TH14) {
digitalWrite(15, HIGH);
}
else if (VA14 < TH14) {
digitalWrite(15, LOW);
}
if (VA15 > TH15) {
digitalWrite(16, HIGH);
}
else if (VA15 < TH15) {
digitalWrite(16, LOW);
}
}
void audio () {
if (ZER = (VA0 > TH0)) count++;
if (ONE = (VA1 > TH1)) count++;
if (TWO = (VA2 > TH2)) count++;
if (THR = (VA3 > TH3)) count++;
if (FOU = (VA4 > TH4)) count++;
if (FIV = (VA5 > TH5)) count++;
if (SIX = (VA6 > TH6)) count++;
if (SEV = (VA7 > TH7)) count++;
if (EIG = (VA8 > TH8)) count++;
if (NIN = (VA9 > TH9)) count++;
if (TEN = (VA10 > TH10)) count++;
if (ELE = (VA11 > TH11)) count++;
if (TWE = (VA12 > TH12)) count++;
if (THT = (VA13 > TH13)) count++;
if (FOT = (VA14 > TH14)) count++;
if (FIV = (VA15 > TH15)) count++;
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
}
if (!ZER) {
Insta.pause (true);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
}
if (!ONE) {
Instb.pause (true);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
}
if (!TWO) {
Instc.pause (true);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
}
if (!THR) {
Instd.pause (true);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
}
if (!FOU) {
Inste.pause (true);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
}
if (!FIV) {
Instf.pause (true);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
}
if (!SIX) {
Instg.pause (true);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
}
if (!SEV) {
Insth.pause (true);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
}
if (!EIG) {
Insti.pause (true);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
}
if (!NIN) {
Instk.pause (true);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
}
if (!TEN) {
Instk.pause (true);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
}
if (!ELE) {
Instl.pause (true);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
}
if (!TWE) {
Instm.pause (true);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
}
if (!THT) {
Instn.pause (true);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
}
if (!FOT) {
Insto.pause (true);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
}
if (!FIT) {
Instp.pause (true);
}
Serial.print("Intruments playing = ");
Serial.println(count);
}

@ -0,0 +1,767 @@
#include <MusicWithoutDelay.h>
//#include <synth.h>
//#include <tables.h>
#include <Wire.h>
#include <Adafruit_ADS1015.h>
//multiplexer adresses
Adafruit_ADS1115 adsa (0x48);
Adafruit_ADS1115 adsb (0x49);
Adafruit_ADS1115 adsc (0x4A);
Adafruit_ADS1115 adsd (0x4B);
//note values
const char note0[] PROGMEM = ":d=128,b=600,o=3:c+"; //plays c4
const char note1[] PROGMEM = ":d=128,b=600,o=3:d+"; //plays d4
const char note2[] PROGMEM = ":d=128,b=600,o=3:e+"; //plays e4
const char note3[] PROGMEM = ":d=128,b=600,o=3:g+"; //plays g4
const char note4[] PROGMEM = ":d=128,b=600,o=3:a+"; //plays a4
const char note5[] PROGMEM = ":d=128,b=600,o=4:c+"; //plays c5
const char note6[] PROGMEM = ":d=128,b=600,o=4:d+"; //plays d5
const char note7[] PROGMEM = ":d=128,b=600,o=4:e+"; //plays e5
const char note8[] PROGMEM = ":d=128,b=600,o=4:g+"; //plays g5
const char note9[] PROGMEM = ":d=128,b=600,o=4:a+"; //plays a5
const char note10[] PROGMEM = ":d=128,b=600,o=5:c+"; //plays c6
const char note11[] PROGMEM = ":d=128,b=600,o=5:d+"; //plays d6
const char note12[] PROGMEM = ":d=128,b=600,o=5:e+"; //plays e6
const char note13[] PROGMEM = ":d=128,b=600,o=5:g+"; //plays g6
const char note14[] PROGMEM = ":d=128,b=600,o=5:a+"; //plays a6
const char note15[] PROGMEM = ":d=128,b=600,o=6:c+"; //plays c7
//instruments
MusicWithoutDelay Insta(note0);
MusicWithoutDelay Instb(note1);
MusicWithoutDelay Instc(note2);
MusicWithoutDelay Instd(note3);
MusicWithoutDelay Inste(note4);
MusicWithoutDelay Instf(note5);
MusicWithoutDelay Instg(note6);
MusicWithoutDelay Insth(note7);
MusicWithoutDelay Insti(note8);
MusicWithoutDelay Instj(note9);
MusicWithoutDelay Instk(note10);
MusicWithoutDelay Instl(note11);
MusicWithoutDelay Instm(note12);
MusicWithoutDelay Instn(note13);
MusicWithoutDelay Insto(note14);
MusicWithoutDelay Instp(note15);
int count;
//int vol;
int VA0, VA1, VA2, VA3, VA4, VA5, VA6, VA7, VA8, VA9, VA10, VA11, VA12, VA13, VA14, VA15;
int TH0, TH1, TH2, TH3, TH4, TH5, TH6, TH7, TH8, TH9, TH10, TH11, TH12, TH13, TH14, TH15;
int VOL0, VOL1, VOL2, VOL3, VOL4, VOL5, VOL6, VOL7, VOL8, VOL9, VOL10, VOL11, VOL12, VOL13, VOL14, VOL15;
bool CV;
int ZER;
int ONE;
int TWO;
int THR;
int FOU;
int FIV;
int SIX;
int SEV;
int EIG;
int NIN;
int TEN;
int ELE;
int TWE;
int THT;
int FOT;
int FIT;
void setup() {
Serial.begin(115200);
//set the gain for multiplexed INs
adsa.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
adsb.setGain(GAIN_ONE);
adsc.setGain(GAIN_ONE);
adsd.setGain(GAIN_ONE);
Serial.println("Ini MPX ");
adsa.begin();
adsb.begin();
adsc.begin();
adsd.begin();
Serial.println("MPX Ini");
Serial.println("Wait4MWD");
Serial.println("Ini MWD");
calib();
Insta.begin(CHA, TRIANGLE, ENVELOPE0, 0);
Instb.begin(TRIANGLE, ENVELOPE0, 0);
Instc.begin(TRIANGLE, ENVELOPE0, 0);
Instd.begin(TRIANGLE, ENVELOPE0, 0);
Inste.begin(TRIANGLE, ENVELOPE0, 0);
Instf.begin(TRIANGLE, ENVELOPE0, 0);
Instg.begin(TRIANGLE, ENVELOPE0, 0);
Insth.begin(TRIANGLE, ENVELOPE0, 0);
Insti.begin(TRIANGLE, ENVELOPE0, 0);
Instj.begin(TRIANGLE, ENVELOPE0, 0);
Instk.begin(TRIANGLE, ENVELOPE0, 0);
Instl.begin(TRIANGLE, ENVELOPE0, 0);
Instm.begin(TRIANGLE, ENVELOPE0, 0);
Instn.begin(TRIANGLE, ENVELOPE0, 0);
Insto.begin(TRIANGLE, ENVELOPE0, 0);
Instp.begin(TRIANGLE, ENVELOPE0, 0);
Insta.pause(true);
Instb.pause(true);
Instc.pause(true);
Instd.pause(true);
Inste.pause(true);
Instf.pause(true);
Instg.pause(true);
Insth.pause(true);
Insti.pause(true);
Instj.pause(true);
Instk.pause(true);
Instl.pause(true);
Instm.pause(true);
Instn.pause(true);
Insto.pause(true);
Instp.pause(true);
Serial.println("go!");
}
void calib() {
//calibrate the LDRs
Serial.println ("Calib");
TH0 = (adsa.readADC_SingleEnded(0) + 800);
TH1 = (adsa.readADC_SingleEnded(1) + 800);
TH2 = (adsa.readADC_SingleEnded(2) + 800);
TH3 = (adsa.readADC_SingleEnded(3) + 800);
TH4 = (adsb.readADC_SingleEnded(0) + 800);
TH5 = (adsb.readADC_SingleEnded(1) + 800);
TH6 = (adsb.readADC_SingleEnded(2) + 800);
TH7 = (adsb.readADC_SingleEnded(3) + 800);
TH8 = (adsc.readADC_SingleEnded(0) + 800);
TH9 = (adsc.readADC_SingleEnded(1) + 800);
TH10 = (adsc.readADC_SingleEnded(2) + 800);
TH11 = (adsc.readADC_SingleEnded(3) + 800);
TH12 = (adsd.readADC_SingleEnded(0) + 800);
TH13 = (adsd.readADC_SingleEnded(1) + 800);
TH14 = (adsd.readADC_SingleEnded(2) + 800);
TH15 = (adsd.readADC_SingleEnded(3) + 800);
Serial.print ("TH0=");
Serial.println (TH0);
Serial.print ("TH1=");
Serial.println (TH1);
Serial.print ("TH2=");
Serial.println (TH2);
Serial.print ("TH3=");
Serial.println (TH3);
Serial.print ("TH4=");
Serial.println (TH4);
Serial.print ("TH5=");
Serial.println (TH5);
Serial.print ("TH6=");
Serial.println (TH6);
Serial.print ("TH7=");
Serial.println (TH7);
Serial.print ("TH8=");
Serial.println (TH8);
Serial.print ("TH9=");
Serial.println (TH9);
Serial.print ("TH10=");
Serial.println (TH10);
Serial.print ("TH11=");
Serial.println (TH11);
Serial.print ("TH12=");
Serial.println (TH12);
Serial.print ("TH13=");
Serial.println (TH13);
Serial.print ("TH14=");
Serial.println (TH14);
Serial.print ("TH15=");
Serial.println (TH15);
}
void loop() {
CV = digitalRead(20);
count = 0;
Insta.update();
Instb.update();
Instc.update();
Instd.update();
Inste.update();
Instf.update();
Instg.update();
Insth.update();
Insti.update();
Instj.update();
Instk.update();
Instl.update();
Instm.update();
Instn.update();
Insto.update();
Instp.update();
//Messure LDR inputs
VA0 = adsa.readADC_SingleEnded(0);
VA1 = adsa.readADC_SingleEnded(1);
VA2 = adsa.readADC_SingleEnded(2);
VA3 = adsa.readADC_SingleEnded(3);
// Serial.print("VA0: "); Serial.println(VA0);
// Serial.print("VA1: "); Serial.println(VA1);
// Serial.print("VA2: "); Serial.println(VA2);
// Serial.print("VA3: "); Serial.println(VA3);
// Serial.println(" ");
VA4 = adsb.readADC_SingleEnded(0);
VA5 = adsb.readADC_SingleEnded(1);
VA6 = adsb.readADC_SingleEnded(2);
VA7 = adsb.readADC_SingleEnded(3);
// Serial.print("VA4: "); Serial.println(VA4);
// Serial.print("VA5: "); Serial.println(VA5);
// Serial.print("VA6: "); Serial.println(VA6);
// Serial.print("VA7: "); Serial.println(VA7);
// Serial.println(" ");
VA8 = adsc.readADC_SingleEnded(0);
VA9 = adsc.readADC_SingleEnded(1);
VA10 = adsc.readADC_SingleEnded(2);
VA11 = adsc.readADC_SingleEnded(3);
// Serial.print("VA8: "); Serial.println(VA8);
// Serial.print("VA9: "); Serial.println(VA9);
// Serial.print("VA10: "); Serial.println(VA10);
// Serial.print("VA11: "); Serial.println(VA11);
// Serial.println(" ");
VA12 = adsd.readADC_SingleEnded(0);
VA13 = adsd.readADC_SingleEnded(1);
VA14 = adsd.readADC_SingleEnded(2);
VA15 = adsd.readADC_SingleEnded(3);
// Serial.print("VA12: "); Serial.println(VA12);
// Serial.print("VA13: "); Serial.println(VA13);
// Serial.print("VA14: "); Serial.println(VA14);
// Serial.print("VA15: "); Serial.println(VA15);
// Serial.println(" ");
if (!CV) {
control();
}
if (CV) {
audio();
}
if (digitalRead(17) == LOW) {
calib();
}
}
void control() {
ZER = false;
ONE = false;
TWO = false;
THR = false;
FOU = false;
FIV = false;
SIX = false;
SEV = false;
EIG = false;
NIN = false;
TEN = false;
ELE = false;
TWE = false;
THT = false;
FOT = false;
FIT = false;
if (VA0 > TH0) {
digitalWrite(0, HIGH);
}
else if (VA0 < TH0) {
digitalWrite(0, LOW);
}
if (VA1 > TH1) {
digitalWrite(1, HIGH);
}
else if (VA1 < TH1) {
digitalWrite(1, LOW);
}
if (VA2 > TH2) {
digitalWrite(2, HIGH);
}
else if (VA2 < TH2) {
digitalWrite(2, LOW);
}
if (VA3 > TH3) {
digitalWrite(4, HIGH);
}
else if (VA3 < TH3) {
digitalWrite(4, LOW);
}
if (VA4 > TH4) {
digitalWrite(5, HIGH);
}
else if (VA4 < TH4) {
digitalWrite(5, LOW);
}
if (VA5 > TH5) {
digitalWrite(7, HIGH);
}
else if (VA5 < TH5) {
digitalWrite(7, LOW);
}
if (VA6 > TH6) {
digitalWrite(6, HIGH);
}
else if (VA6 < TH6) {
digitalWrite(6, LOW);
}
if (VA7 > TH7) {
digitalWrite(8, HIGH);
}
else if (VA7 < TH7) {
digitalWrite(8, LOW);
}
if (VA8 > TH8) {
digitalWrite(9, HIGH);
}
else if (VA8 < TH8) {
digitalWrite(9, LOW);
}
if (VA9 > TH9) {
digitalWrite(10, HIGH);
}
else if (VA9 < TH9) {
digitalWrite(10, LOW);
}
if (VA10 > TH10) {
digitalWrite(12, HIGH);
}
else if (VA10 < TH10) {
digitalWrite(12, LOW);
}
if (VA11 > TH11) {
digitalWrite(11, HIGH);
}
else if (VA11 < TH11) {
digitalWrite(11, LOW);
}
if (VA12 > TH12) {
digitalWrite(13, HIGH);
}
else if (VA12 < TH12) {
digitalWrite(13, LOW);
}
if (VA13 > TH13) {
digitalWrite(14, HIGH);
}
else if (VA13 < TH13) {
digitalWrite(14, LOW);
}
if (VA14 > TH14) {
digitalWrite(15, HIGH);
}
else if (VA14 < TH14) {
digitalWrite(15, LOW);
}
if (VA15 > TH15) {
digitalWrite(16, HIGH);
}
else if (VA15 < TH15) {
digitalWrite(16, LOW);
}
}
void audio () {
digitalWrite(0, LOW);
digitalWrite(1, LOW);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
digitalWrite(6, LOW);
digitalWrite(7, LOW);
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
digitalWrite(14, LOW);
digitalWrite(15, LOW);
digitalWrite(16, LOW);
if (VA0 > TH0) {
count++;
ZER = true;
}
else if (VA0 < TH0) {
ZER = false;
}
if (VA1 > TH1) {
count++;
ONE = true;
}
else if (VA1 < TH1) {
ONE = false;
}
if (VA2 > TH2) {
count++;
TWO = true;
}
else if (VA2 < TH2) {
TWO = false;
}
if (VA3 > TH3) {
count++;
THR = true;
}
else if (VA3 < TH3) {
THR = false;
}
if (VA4 > TH4) {
count++;
FOU = true;
}
else if (VA4 < TH4) {
FOU = false;
}
if (VA5 > TH5) {
count++;
FIV = true;
}
else if (VA5 < TH5) {
FIV = false;
}
if (VA6 > TH6) {
count++;
SIX = true;
}
else if (VA6 < TH6) {
SIX = false;
}
if (VA7 > TH7) {
count++;
SEV = true;
}
else if (VA7 < TH7) {
SEV = false;
}
if (VA8 > TH8) {
count++;
EIG = true;
}
else if (VA8 < TH8) {
EIG = false;
}
if (VA9 > TH9) {
count++;
NIN = true;
}
else if (VA9 < TH9) {
NIN = false;
}
if (VA10 > TH10) {
count++;
TEN = true;
}
else if (VA10 < TH10) {
TEN = false;
}
if (VA11 > TH11) {
count++;
ELE = true;
}
else if (VA11 < TH11) {
ELE = false;
}
if (VA12 > TH12) {
count++;
TWE = true;
}
else if (VA12 < TH12) {
TWE = false;
}
if (VA13 > TH13) {
count++;
THT = true;
}
else if (VA13 < TH13) {
THT = false;
}
if (VA14 > TH14) {
count++;
FOT = true;
}
else if (VA14 < TH14) {
FOT = false;
}
if (VA15 > TH15) {
count++;
FIV = true;
}
else if (VA15 < TH15) {
FIV = false;
}
if (ZER) {
VOL0 = 50/count+constrain(map(VA0, TH0, TH0+5000, 0, 65), 0, 65);
Insta.play(true);
Insta.setVolume(VOL0);
// Serial.print("Tone0 active at vol:");
// Serial.println(VOL0);
// Serial.println(VA0);
}
if (!ZER) {
Insta.pause (true);
}
if (ONE) {
VOL1 = 50/count+constrain(map(VA1, TH1, TH1+5000, 0, 65), 0, 65);
Instb.play(true);
Instb.setVolume(VOL1);
// Serial.print("Tone1 active at vol:");
// Serial.println(VOL1);
// Serial.println(VA1);
}
if (!ONE) {
Instb.pause (true);
}
if (TWO) {
VOL2 = 50/count+constrain(map(VA2, TH2, TH2+5000, 0, 65), 0, 65);
Instc.play(true);
Instc.setVolume(VOL2);
// Serial.print("Tone2 active at vol:");
// Serial.println(VOL2);
// Serial.println(VA2);
}
if (!TWO) {
Instc.pause (true);
}
if (THR) {
VOL3 = 50/count+constrain(map(VA3, TH3, TH3+5000, 0, 65), 0, 65);
Instd.play(true);
Instd.setVolume(VOL3);
// Serial.print("Tone3 active at vol:");
// Serial.println(VOL3);
// Serial.println(VA3);
}
if (!THR) {
Instd.pause (true);
}
if (FOU) {
VOL4 = 50/count+constrain(map(VA4, TH4, TH4+5000, 0, 65), 0, 65);
Inste.play(true);
Inste.setVolume(VOL4);
// Serial.print("Tone4 active at vol:");
// Serial.println(VOL4);
// Serial.println(VA4);
}
if (!FOU) {
Inste.pause (true);
}
if (FIV) {
VOL5 = 50/count+constrain(map(VA5, TH5, TH5+5000, 0, 65), 0, 65);
Instf.play(true);
Instf.setVolume(VOL5);
// Serial.print("Tone5 active at vol:");
// Serial.println(VOL5);
// Serial.println(VA5);
}
if (!FIV) {
Instf.pause (true);
}
if (SIX) {
VOL6 = 50/count+constrain(map(VA6, TH6, TH6+5000, 0, 65), 0, 65);
Instg.play(true);
Instg.setVolume(VOL6);
// Serial.print("Tone6 active at vol:");
// Serial.println(VOL6);
// Serial.println(VA6);
}
if (!SIX) {
Instg.pause (true);
}
if (SEV) {
VOL7 = 50/count+constrain(map(VA7, TH7, TH7+5000, 0, 65), 0, 65);
Insth.play(true);
Insth.setVolume(VOL7);
// Serial.print("Tone7 active at vol:");
// Serial.println(VOL7);
// Serial.println(VA7);
}
if (!SEV) {
Insth.pause (true);
}
if (EIG) {
VOL8 = 50/count+constrain(map(VA8, TH8, TH8+5000, 0, 65), 0, 65);
Insti.play(true);
Insti.setVolume(VOL8);
// Serial.print("Tone8 active at vol:");
// Serial.println(VOL8);
// Serial.println(VA8);
}
if (!EIG) {
Insti.pause (true);
}
if (NIN) {
VOL9 = 50/count+constrain(map(VA9, TH9, TH9+5000, 0, 65), 0, 65);
Instj.play(true);
Instj.setVolume(VOL9);
// Serial.print("Tone9 active at vol:");
// Serial.println(VOL9);
// Serial.println(VA9);
}
if (!NIN) {
Instk.pause (true);
}
if (TEN) {
VOL10 = 50/count+constrain(map(VA10, TH10, TH10+5000, 0, 65), 0, 65);
Instk.play(true);
Instk.setVolume(VOL10);
// Serial.print("Tone10 active at vol:");
// Serial.println(VOL10);
// Serial.println(VA10);
}
if (!TEN) {
Instk.pause (true);
}
if (ELE) {
VOL11 = 50/count+constrain(map(VA11, TH11, TH11+5000, 0, 65), 0, 65);
Instl.play(true);
Instl.setVolume(VOL11);
// Serial.print("Tone11 active at vol:");
// Serial.println(VOL11);
// Serial.println(VA11);
}
if (!ELE) {
Instl.pause (true);
}
if (TWE) {
VOL12 = 50/count+constrain(map(VA12, TH12, TH12+5000, 0, 65), 0, 65);
Instm.play(true);
Instm.setVolume(VOL12);
// Serial.print("Tone12 active at vol:");
// Serial.println(VOL12);
// Serial.println(VA12);
}
if (!TWE) {
Instm.pause (true);
}
if (THT) {
VOL13 = 50/count+constrain(map(VA13, TH13, TH13+5000, 0, 65), 0, 65);
Instn.play(true);
Instn.setVolume(VOL13);
// Serial.print("Tone13 active at vol:");
// Serial.println(VOL13);
// Serial.println(VA13);
}
if (!THT) {
Instn.pause (true);
}
if (FOT) {
VOL14 = 50/count+constrain(map(VA14, TH14, TH14+5000, 0, 65), 0, 65);
Insto.play(true);
Insto.setVolume(VOL14);
// Serial.print("Tone14 active at vol:");
// Serial.println(VOL14);
// Serial.println(VA14);
}
if (!FOT) {
Insto.pause (true);
}
if (FIT) {
VOL15 = 50/count+constrain(map(VA15, TH15, TH15+5000, 0, 65), 0, 65);
Instp.play(true);
Instp.setVolume(VOL15);
// Serial.print("Tone15 active at vol:");
// Serial.println(VOL15);
// Serial.println(VA15);
}
if (!FIT) {
Instp.pause (true);
}
}
// Serial.print("Intruments playing = ");
// Serial.println(count);
//Play notes and mix down (set volume depending on number of notes playing)
Loading…
Cancel
Save