Heres what my hardware looks like.
1x Arduino board .
5x Small LDR Light Resistor (it costs $ cents and are very precise)
5x 10K Resistor
5x meters of thin and flexible solid core wire.
1x Protoboard and a bunch Jumper cables;
1x USB or Serial cable to connect Arduino -> MAC.
file:///Users/shawntperished/Downloads/IMG_20131212_143231_266.jpg
http://www.instructables.com/files/deriv/FBA/Y5SV/GJQEIOFT/FBAY5SVGJQEIOFT.LARGE.jpg (already posted)
https://gm2.ggpht.com/PPv7AVdGUn_r5BPfiDgl5eCnK7isucoWxIyfxDTZmJQ0_So4VbQE_44Rls6QtEHNiDX6x3KiMg5cM2E1mzUqn1FPdyG7btnpztiPHRxw8P5j1ptA0dpYgGimipgXrcmWSPV7zwYnyRpCw_UfomkZ8aZxEeemgxVD12D_fz-jj1DCkpCnOC7s1oA-aSE7_xDhASEYs7vl-PHpsvDe5cEagxT3byIYPLgNaTmirOabLXmO3tSh_ro_BiJMQGYEwWJF5Fh9-0HWuKfv3qlBVUCtAapPcBx8JZ8GgKvqTnVDy25hFnrQAcGb9bXzM7KaGLA78pcdL6HPdrF44Q5TP3oZnQnMReijsZdTynB9Yd6B075GPg5bMEcEHT6Zg7bv7n-w4kSP4CrDmebZU9huOqkLrK00Eqeq_plVyjp-urBB7STdwLP6TtrsQt-gwN-dg37g3-bAjHq16Y_CCLYGcwNBxGwj9Db21zCXtf0oqxyVHDkl4Gp6Rfecx1WDGGzRQEoTuRvkqvu2PFleS7pLYM-w-sOpJeNPfYgh9A=w912-h479-l75
So the board would look like:
Wire #1 - connects 5v port and 4 LDR leads in a common and shared line.
Wire #2 - White: Connects LDR from Finger 1 to Analog IN Port 0
Wire #3 - White: Connects LDR from Finger 2 to Analog IN Port 1
Wire #4 - White: Connects LDR from Finger 3 to Analog IN Port 2
Wire #5 - White: Connects LDR from Finger 4 to Analog IN Port 3
All wires share 5v port.
(on another note). I am also confused on how the the sound generator app will communicate with the serial port(I've read things along the lines of midi port drivers.... If you have any thoughts on that.
And the code I'm using is.
unsigned char PadNote[4] = {45,55,60,67}; // MIDI notes from 0 to 127 (Mid C = 60)
// Imagine a piano roll. 45 55 are keys located on the middle for example.
// Tweak it to what sounds better to you.
int CutOff = 40; // This is the minimal amount of analog reading before triggering the note!
int MaxPlayTime[6] = {6500,6500,6500,6500}; // Cycles before a 2nd hit is allowed
// Best value after lots of trial and error.
#define midichannel 0; // MIDI channel from 0 to 15 (+1 in "real world")
//*******************************************************************************************************************
// Internal Use Variables
//
// You should tweak here if it's not optimal yet.
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// Those values work perfectly when using the small LDR and 1K Resistor. So used it!
//
//*******************************************************************************************************************
boolean activePad[6] = {0,0,0,0}; // Array of flags of pad currently playing
int PinPlayTime[6] = {0,0,0,0}; // Counter since pad started to play
int ActivePadMinTime = 100;
int PinPauseTimeDelay = 200;
int PinPauseTime[4] = {0,0,0,0};
int PinAvailable[4] = {1,1,1,1};
unsigned char status;
int pin = 0;
int hitavg = 0;
int maxread = 0;
int debug = false;
int noteOffset = 0;
//*******************************************************************************************************************
// Setup
//*******************************************************************************************************************
void setup()
{
Serial.begin(57600); // connect to the serial port 57600
}
//*******************************************************************************************************************
// Main Program
//*******************************************************************************************************************
void loop()
{
for(int pin=0; pin <= 3; pin++)
{
hitavg = analogRead(pin); // read the input pin
if(debug)
Serial.println(hitavg);
if(hitavg < CutOff) {
if(debug)Serial.println("hitavg < CutOff");
if(activePad[pin] == false) {
if(debug) Serial.println("activePad[pin] == false");
if(PinAvailable[pin] == true)
{
if(debug) Serial.println("PinAvailable[pin] == true");
// Toca a nota full
activePad[pin] = true;
PinPauseTime[pin] = 0;
MIDI_TX((0x90 | pin), PadNote[pin]+noteOffset, 127);
if(debug) Serial.println("NoteON");
}
}
}
if(activePad[pin] == true) {
if(debug)Serial.println("activePad[pin] == true");
PinPlayTime[pin] += 1;
if(analogRead(pin) > CutOff && PinPlayTime[pin] > ActivePadMinTime)
{
if(debug) Serial.println("analogRead(pin) > PadCut == TRUE");
activePad[pin] = false;
PinAvailable[pin] = 2;
if(debug)
Serial.println("NoteOFF, available is now false. active is false;");
MIDI_TX((0x80 | pin), PadNote[pin]+noteOffset, 50);
PinPlayTime[pin] = 0;
}
}
if(PinAvailable[pin] == 2 && PinPauseTime[pin] > PinPauseTimeDelay) {
if(debug)Serial.println("PinAvailable[pin] == false && PinPauseTime[pin] > 10");
PinAvailable[pin] = true;
} else if(PinAvailable[pin] == 2) {
if(debug)Serial.println("PinPauseTime[pin] += 1;");
PinPauseTime[pin] += 1;
}
if(debug)delay(1000);
}
}
//*******************************************************************************************************************
// Transmit MIDI Message
//*******************************************************************************************************************
void MIDI_TX(byte MESSAGE, unsigned char PITCH, unsigned char VELOCITY)
{
//status = MESSAGE + midichannel;
//status = MESSAGE + pin;
digitalWrite(13,HIGH);
Serial.print(MESSAGE, BYTE);
Serial.print(PITCH);
Serial.print(VELOCITY);
delay(30);
digitalWrite(13,LOW);
}/code]
Heres the response I get from the arduino software
[code]sketch_dec12a:1: error: expected constructor, destructor, or type conversion before 'char'
sketch_dec12a.ino: In function 'void loop()':
sketch_dec12a:71: error: 'PadNote' was not declared in this scope
sketch_dec12a:71: error: 'MIDI_TX' was not declared in this scope
sketch_dec12a:91: error: 'PadNote' was not declared in this scope
sketch_dec12a:91: error: 'MIDI_TX' was not declared in this scope
sketch_dec12a.ino: At global scope:
sketch_dec12a:113: error: variable or field 'MIDI_TX' declared void
sketch_dec12a:113: error: no matching function for call to 'HardwareSerial::write()'
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.h:62: note: candidates are: virtual size_t HardwareSerial::write(uint8_t)
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.h:63: note: size_t HardwareSerial::write(long unsigned int)
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.h:64: note: size_t HardwareSerial::write(long int)
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.h:65: note: size_t HardwareSerial::write(unsigned int)
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/HardwareSerial.h:66: note: size_t HardwareSerial::write(int)
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:53: note: virtual size_t Print::write(const uint8_t*, size_t)
/Users/shawntperished/Desktop/untitled folder/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:49: note: size_t Print::write(const char*)
sketch_dec12a:113: error: expected primary-expression before 'unsigned'
sketch_dec12a:113: error: expected primary-expression before 'unsigned'/code]
[/code]