Home › Forums › Mux Shield (Original) Support › Mark, Please Please Please HELP me with your original MUX Shield product
- This topic has 0 replies, 1 voice, and was last updated 7 years, 11 months ago by justinmenzel1.
-
AuthorPosts
-
December 21, 2015 at 11:40 am #1360justinmenzel1Participant
Hi Mark,
I am running out of options on my project here to get it working.
I have built a 48 key Midi Marimba using the Arduino Mega and your Mux Shield with 48 Piezo sensors.
Everything is working properly when the Piezo discs are hit softly, but when they are hit at a normal strength, they trigger all kinds of chords and wacky notes. I know that you are thinking that the vibration is affecting the other discs, but I have confirmed with Piezo isolation that is not the case.This thread here seems to say that your MUX Shield simply does not work with Piezo discs properly.
https://forum.sparkfun.com/viewtopic.php?f=32&t=35546
I hope that this is not the case.My code is attached and I would be happy to talk further about this project. It is a fantastic project that I have been working super hard on, and I really need your help getting this to work.
Thanks so much!!!!
Justin 610-283-7633
(Code Below)
// <http://forum.arduino.cc/index.php?topic=366478.0>
#define COUNT_ENTRIES(ARRAY) (sizeof(ARRAY) / sizeof(ARRAY[0]))
const uint8_t pinCONTROL0 = 5;
const uint8_t pinCONTROL1 = 4;
const uint8_t pinCONTROL2 = 3;
const uint8_t pinCONTROL3 = 2;struct pad_t
{
uint32_t active : 1; // 1 false/true
uint32_t note : 7; // 8 0 – 127
uint32_t velocity : 10; // 18 0 – 1023
uint32_t play_time : 7; // 25 0 – 127
uint32_t play_timeMAX: 7; // 32 0 – 127
};struct pad_t pads[][3] =
{
// ADC0 ADC1 ADC2{ { false, 51, 400, 0, 90 }, { false, 67, 400, 0, 90 }, { false, 83, 400, 0, 90 } } // PAD 15, 31, 47
, { { false, 50, 400, 0, 90 }, { false, 66, 400, 0, 90 }, { false, 82, 400, 0, 90 } } // PAD 14, 30, 46
, { { false, 49, 400, 0, 90 }, { false, 65, 400, 0, 90 }, { false, 81, 400, 0, 90 } } // PAD 13, 29, 45
, { { false, 48, 400, 0, 90 }, { false, 64, 400, 0, 90 }, { false, 80, 400, 0, 90 } } // PAD 12, 28, 44
, { { false, 47, 400, 0, 90 }, { false, 63, 400, 0, 90 }, { false, 79, 400, 0, 90 } } // PAD 11, 27, 43
, { { false, 46, 400, 0, 90 }, { false, 62, 400, 0, 90 }, { false, 78, 400, 0, 90 } } // PAD 10, 26, 42
, { { false, 45, 400, 0, 90 }, { false, 61, 400, 0, 90 }, { false, 77, 400, 0, 90 } } // PAD 9, 25, 41
, { { false, 44, 400, 0, 90 }, { false, 60, 400, 0, 90 }, { false, 76, 400, 0, 90 } } // PAD 8, 24, 40
, { { false, 43, 400, 0, 90 }, { false, 59, 400, 0, 90 }, { false, 75, 400, 0, 90 } } // PAD 7, 23, 39
, { { false, 42, 400, 0, 90 }, { false, 58, 400, 0, 90 }, { false, 74, 400, 0, 90 } } // PAD 6, 22, 38
, { { false, 41, 400, 0, 90 }, { false, 57, 400, 0, 90 }, { false, 73, 400, 0, 90 } } // PAD 5, 21, 37
, { { false, 40, 400, 0, 90 }, { false, 56, 400, 0, 90 }, { false, 72, 400, 0, 90 } } // PAD 4, 20, 36
, { { false, 39, 400, 0, 90 }, { false, 55, 400, 0, 90 }, { false, 71, 400, 0, 90 } } // PAD 3, 19, 35
, { { false, 38, 400, 0, 90 }, { false, 54, 400, 0, 90 }, { false, 70, 400, 0, 90 } } // PAD 2, 18, 34
, { { false, 37, 400, 0, 90 }, { false, 53, 400, 0, 90 }, { false, 69, 400, 0, 90 } } // PAD 1, 17, 33
, { { false, 36, 400, 0, 90 }, { false, 52, 400, 0, 90 }, { false, 68, 400, 0, 90 } } // PAD 0, 16, 32
};// MIDI channel from 0 to 15 ( 1-16 in “real world”)
const uint8_t MIDI_CHANNEL = 0;// Velocity ON (true) or OFF (false)
bool fVelocity = true;void midi_send(uint8_t midi_message, uint8_t pitch, uint8_t midi_velocity)
{
Serial.write(midi_message + MIDI_CHANNEL);
Serial.write(pitch);
Serial.write(midi_velocity);
}void do_channel(uint8_t const pinADC, struct pad_t& pad)
{
int velocity = analogRead(pinADC);if ( velocity > pad.velocity )
{
if ( ! pad.active )
{
pad.active = true;
pad.play_time = 0;velocity = fVelocity ? ((velocity / 8) – 1) : 127;
midi_send(144, pad.note, velocity)
;}
else
{
++pad.play_time;
}
}
else if ( pad.active )
{
if ( ++pad.play_time > pad.play_timeMAX )
{
pad.active = false;midi_send(144, pad.note, 0);
}
}
}void loop()
{
const int ROWS = COUNT_ENTRIES(pads);
const int COLUMNS = COUNT_ENTRIES(pads[0]);for ( size_t iROW = 0; iROW < ROWS; iROW++ )
{
// … MULTIPLEX SELECTOR …
// digitalWrite(pinCONTROL0, (iROW & 0x1111) >> 3);
// digitalWrite(pinCONTROL1, (iROW & 0x0111) >> 2);
// digitalWrite(pinCONTROL2, (iROW & 0x0011) >> 1);
// digitalWrite(pinCONTROL3, (iROW & 0x0001) >> 0);
digitalWrite(pinCONTROL0, (iROW&15)>>3);
digitalWrite(pinCONTROL1, (iROW&7)>>2);
digitalWrite(pinCONTROL2, (iROW&3)>>1);
digitalWrite(pinCONTROL3, (iROW&1));// … 3 CHANNELS A0, A1 and A2 …
const uint8_t pinsADC[COLUMNS] = { A0, A1, A2 };for ( size_t iCOLUMN = 0; iCOLUMN < COLUMNS; iCOLUMN++ )
{
do_channel(pinsADC[iCOLUMN], pads[iROW][iCOLUMN]);
}
}
}void setup()
{
pinMode(pinCONTROL0, OUTPUT);
pinMode(pinCONTROL1, OUTPUT);
pinMode(pinCONTROL2, OUTPUT);
pinMode(pinCONTROL3, OUTPUT);Serial.begin(115200);
}
-
AuthorPosts
- You must be logged in to reply to this topic.