I was wondering about that. How fast a hardware pulldown occurs VS how fast the arduino loops. But it behaves ok. So if it isn't broken don't fix it, right?
Now that that works I need to figure out how to release it so that I can slide my finger over the ribbon triggering notes form a scale.
I am currently blocking the polling of the sensor by how I wrote my code so the value does not update and the note won't change. Can you point me in the right direction please?
#include <MIDI.h>
int posPin = A0;
int posVal = 0;
int note = 0;
int tempVal = 0;
int led = 13;
int scale[] = {
60,62,64,65,67,69,71};
#define LED 13
void setup() {
pinMode(LED, OUTPUT);
MIDI.begin(); // Launch MIDI with default options
}
void loop(){
readPos();
}
void readPos(){
tempVal = analogRead(posPin);
if(tempVal == 0) {
MIDI.sendControlChange(123,0,1); // OMNI NOTE OFF MSG
digitalWrite(led, LOW);
}
if(tempVal !=0) {
posVal = tempVal;
posVal = map(posVal, 1023, 1, 127, 0); // make midi notes
posVal = constrain(posVal, 0, 127); // constrain it
note = map(tempVal, 1023, 1, 6, 0); // make it 7 for the note array
note = constrain(note, 0, 6); // constrain it
note = scale[note]; // pick a note
MIDI.sendNoteOn(note,127,1); // send the note (note, velocity, channel)
digitalWrite(led, HIGH);
}
}