Hi all,
I am doing a project on sending MIDI messages from 15 IR sharp sensors. Ones a while i get strange blinks and the piezo that i use for testing suddenly bleeps (in this case 14) a sensor. cant understand why as the value is so that it shouldnt. Any ideas what am doing wrong ?
#include <MIDI.h>
#include <DmxSimple.h>
const byte channel[15] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
const byte playingNote[15] = {49,51,54,56,58,61,63,66,68,70,73,75,78,80,82};
int i;
int piez = 8;
int tones[15]={2000,2200,2500,2700,2900,3100,3300,3500,3600,3800,4200,4400,4600,5000,5200};
const int input[15]={A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14};
int sensing[15];
int pitch[15];
MIDI_CREATE_DEFAULT_INSTANCE();
int noteStatus[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
void setup() {
Serial.begin(9600);
// MIDI.begin();
DmxSimple.usePin(3);
DmxSimple.maxChannel(4);
}
void loop(){
for(i=0;i<15;i++){
sensing[i] = map(analogRead(input[i]), 0, 550, 150, 0);
pitch[i] = map(analogRead(input[i]), 0, 550, -8190, 8190);
Serial.print("Sensor ");
Serial.print(i);
Serial.print(" : ");
Serial.println(sensing[i]);
if(sensing[i]<127){
MIDI.sendControlChange(1, sensing[i], channel[i]);
MIDI.sendPitchBend(pitch[i], channel[i]);
if(noteStatus[i]==0){
MIDI.sendNoteOn(playingNote[i], sensing[i], channel[i]);
tone(piez, tones[i], 500);
noteStatus[i]=1;
}
}else{
if(noteStatus[i]!=0){
MIDI.sendNoteOff(playingNote[i], 0, channel[i]);
noteStatus[i]=0;
}
}
delay(200);
}
}
// DmxSimple.write(1, brightness);
