Hola a todos! bueno les comento, hice una bateria electonica casera, estoy usan un Arduino Mega 2560 con pisoelectricos como sensores, todo funciona bien hasta que luego de tocar por 1 o 2 minutos, dejan de funcionar algunas entradas analogicas y debo resetearlo.
(Aclaracìón: Dejan de funcionar por un tiempo y luego vuelven a funcionar)
Me podran ayudar, me volvi loco buscando soluciones
Gracias
Codigo:
unsigned char PadNote[11] = {10,35,44,55,50,45,57,43,51,127,126}; // MIDI notes from 0 to 127 (Mid C = 60)
int PadCutOff[11] = {600,1,600,1000,600,600,1000,600,600,600,600}; // Minimum Analog value to cause a drum hit
int MaxPlayTime[11] = {30,1,10,20,30,10,30,10,30,30,30}; // Cycles before a 2nd hit is allowed
#define midichannel 0; // MIDI channel from 0 to 15 (+1 in "real world")
boolean VelocityFlag = true; // Velocity ON (true) or OFF (false)
//*******************************************************************************************************************
// Internal Use Variables
//*******************************************************************************************************************
boolean activePad[11] = {
0,0,0,0,0,0,0,0,0,0,0}; // Array of flags of pad currently playing
int PinPlayTime[11] = {
0,0,0,0,0,0,0,0,0,0,0}; // Counter since pad started to play
unsigned char status;
int pin = 0;
int hitavg = 0;
//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************
void setup()
{
Serial.begin(57600); // connect to the serial port 115200
}
//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************
void loop()
{
for(int pin=0; pin < 11; pin++)
{
hitavg = analogRead(pin); // read the input pin
if((hitavg > PadCutOff[pin]))
{
if((activePad[pin] == false))
{
if(VelocityFlag == true)
{
// hitavg = 127 / ((1023 - PadCutOff[pin]) / (hitavg - PadCutOff[pin])); // With full range (Too sensitive ?)
hitavg = (hitavg / 8) -1 ; // Upper range
}
else
{
hitavg = 127;
}
MIDI_TX(144,PadNote[pin],hitavg);
PinPlayTime[pin] = 0;
activePad[pin] = true;
}
else
{
PinPlayTime[pin] = PinPlayTime[pin] + 1;
}
}
else if((activePad[pin] == true))
{
PinPlayTime[pin] = PinPlayTime[pin] + 1;
if(PinPlayTime[pin] > MaxPlayTime[pin])
{
activePad[pin] = false;
MIDI_TX(128,PadNote[pin],127);
}
}
}
}
//*******************************************************************************************************************
// Transmit MIDI Message
//*******************************************************************************************************************
void MIDI_TX(unsigned char MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
status = MESSAGE + midichannel;
Serial.write(status);
Serial.write(PITCH);
Serial.write(VELOCITY);
}

