Can someone show me how to use the Adafruit-MCP23017-Arduino-Library and http://www.adafruit.com/products/732 MPC23017 to accomplish this.
A perfect example of what I'm trying to do is the midi_footsteps controller, which could be found here: http://www.thebox.myzen.co.uk/Hardware/ ... steps.html or the YAAMI-Drum here: http://blog.georgmill.de/2011/03/22/e-d ... st-gebaut/. I've got the multiplexers and midiout working thanks to Grumpy_mike, Crossroads and others in the Arduino forum. And now the final part is to add the LED section. Can anyone help me get this finale piece in place.
The library:
https://github.com/adafruit/Adafruit-MC ... no-Library
The data sheet:
http://ww1.microchip.com/downloads/en/d ... 21952b.pdf
My wiring:
The sketch goes like this: ( except no muxs are used here, in my actual project I'm using mux-shield i.e. 4051 multiplexers for up to 48 pads and the midi shield for midi OUT ) but you can get the basic idea. It's like a piano with keys that light up or a drum kit with pads that light up on inpact. So noteON = LED on.
Code: Select all
/
// DESCRIPTION:
// Arduino analog input used to sense piezo drum hits then sent serialy to processing.
//*******************************************************************************************************************
// User settable variables
//*******************************************************************************************************************
unsigned char PadNote[6] = {52,16,66,63,40,65}; // MIDI notes from 0 to 127 (Mid C = 60)
int PadCutOff[6] = {600,600,600,600,600,600}; // Minimum Analog value to cause a drum hit
int MaxPlayTime[6] = {90,90,90,90,90,90}; // 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[6] = {0,0,0,0,0,0}; // Array of flags of pad currently playing
int PinPlayTime[6] = {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 < 6; 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 / -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.print(status);
Serial.print(PITCH);
Serial.print(VELOCITY);
}
}
}