I am working on the project using capacitive sensors to trigger MIDI notes. I am able to play single notes no problem. But for my project I would like to play a sequence of 3-4 notes. Would it be possible to write this line to play the selection of 3 notes instead of all notes E 4; F 4; F# 4; G 4; G# 4; A 4(//PAD3////////). Could you tell me how?
for (int note = 0x40; note < 0x45; note ++)
The rest of the code is this
#include <CapacitiveSensor.h>
CapacitiveSensor cs_2_3 = CapacitiveSensor(2,3); //PAD1
CapacitiveSensor cs_2_4 = CapacitiveSensor(2,4); //PAD2
CapacitiveSensor cs_2_5 = CapacitiveSensor(2,5); //PAD3
int sen = 100;//sensitivity of your pads
int noteON = 144;//144 = 10010000 in binary, note on command
void setup() {
Serial.begin(31250); // Set MIDI baud rate:
}
void loop() {
long total1 = cs_2_3.capacitiveSensor(30);
long total2 = cs_2_4.capacitiveSensor(30);
long total3 = cs_2_5.capacitiveSensor(30);
//PAD1////////////////////////////
static int lastInput1 = 0;
int newInput1 = total1;
if((lastInput1 < sen) && (newInput1 > sen)) {
for (int note=50;note<51;note++) {//from note 50 (D3) to note 69 (A4)
MIDImessage(noteON, note, 127);
}
};//turn note on
if((lastInput1 > sen) && (newInput1 < sen)) {
for (int note=50;note<51;note++) {//from note 50 (D3) to note 69 (A4)
MIDImessage(noteON, note, 0);
}
};
lastInput1 = newInput1;
//PAD2///////////////////////
static int lastInput2 = 0;
int newInput2 = total2;
if((lastInput2 < sen) && (newInput2 > sen)) {
for (int note=52;note<53;note++) {//from note 50 (D3) to note 69 (A4)
MIDImessage(noteON, note, 127);
}
};//turn note on
if((lastInput2 > sen) && (newInput2 < sen)) {
for (int note=52;note<53;note++) {//from note 50 (D3) to note 69 (A4)
MIDImessage(noteON, note, 0);
}
};
lastInput2 = newInput2;
//PAD3////////////////////////////
static int lastInput3 = 0;
int newInput3 = total3;
if((lastInput3 < sen) && (newInput3 > sen)) {
for (int note = 0x40; note < 0x45; note ++) {
MIDImessage(noteON, note, 127);
delay(100);
}
};//turn note on
if((lastInput3 > sen) && (newInput3 < sen)) {
for (int note = 0x40; note < 0x45; note ++) {
MIDImessage(noteON, note, 0);
}
};
lastInput3 = newInput3;
}
//send MIDI message///////////////////////////////////////////////////////////////
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
Serial.write(command);//send note on or note off command
Serial.write(MIDInote);//send pitch data
Serial.write(MIDIvelocity);//send velocity data
}