macegr,
Thanks much. Yes the breadboard, but also I no longer have the 4k7 resistors tied to 5V. I'm very new to this stuff so please forgive the misuse of terms and stupid question (not every question can be a "great question!"). Moving on...
Now that I've been able to test the chip now to put it to use. I need to turn the 16 LEDs ON/OFF individually based on the condition of 16 physical switches (piezo sensors to be exact) being ON/ or OFF. So each piezo has a corresponding LED and is either HIGH or LOW.
Can you show me how I may use the centipede shield or one MCP23017 - i2c 16 input/output port expander : ID 732 : $6.95 : Adafruit Industries, Unique & fun DIY electronics and kits MPC23017 chip to accomplish this.
A perfect example of what I'm trying to do is the midi_footsteps controller, it could be found in the playground on it's homepage MIDI Footsteps. I've got the multiplexers work thanks to Grumpy_mike, Crossroads and others. And now the final part it to add the LED section. Can anyone help me get this finale piece in place.
My code goes like this except no muxs are used here ( in my actual project I'm using the mux shield a total of 48 pads and the midi shield to output midi) but you can get the basic idea. It's like a piano with keys that light up or drums with pads that light up on inpact. So noteON = LED on.
SpikenzieLabs offers a pre-written code that looks like this:
/
// 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);
}
}
}
Thanks again
PS: some newly learned teams: GPIO, i2c, wire.h, Mask (computing)...