Still trying to get pin A0 to change the notes of pin A1,
Code:
#include "MIDIUSB.h"
// First parameter is the event type (0x09 = note on, 0x08 = note off).
// Second parameter is note-on/note-off, combined with the channel.
// Channel can be anything between 0-15. Typically reported to the user as 1-16.
// Third parameter is the note number (48 = middle C).
// Fourth parameter is the velocity (64 = normal, 127 = fastest).
void noteOn(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOn = {0x09, 0x90 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOn);
}
void noteOff(byte channel, byte pitch, byte velocity) {
midiEventPacket_t noteOff = {0x08, 0x80 | channel, pitch, velocity};
MidiUSB.sendMIDI(noteOff);
}
void setup() {
Serial.begin(115200);
}
// First parameter is the event type (0x0B = control change).
// Second parameter is the event type, combined with the channel.
// Third parameter is the control number number (0-119).
// Fourth parameter is the control value (0-127).
void loop() {
{
int val;
val = analogRead(A0);
if (val < 10) {
noteOn(0, 36, 127);
MidiUSB.flush();
while (analogRead(A0) < 10) { }
noteOff(0, 36, 127);
MidiUSB.flush();
}
}
int val;
val = analogRead(A1);
if (val > 400) {
if (A0 val > 300); {
send note 38
}
else if (A0 val > 50 < 300) {
send note 39
}
else if (A0 val < 50) {
send note 40
velocity = map (val, 300, 1023, 30, 127);
noteOn(0, 51, velocity);
MidiUSB.flush();
while (analogRead(A1) > 400) { }
noteOff(0, 51, 127);
MidiUSB.flush();
}
}]