so I'm using the ADXL3 and trying to get it to read midi. I've actually had this working in the past with this code, but it's not working anymore and I'm not sure why. I've attached a midi jack's a 220Ohm resistor to MIDI pin 4, ground to MIDI pin 2 and 5V to MIDI pin 5. Like this instructions
I'm using hairless midi and keep getting the error: Warning: got a status byte when were expecting 1 more data types, sending possible incomplete midi messages. I actually gotten this error in the past, but I dont know how i got rid of it.
I have my MIDI out to my Midi man port A with a baud rate of 115200. Is this suppose to be 9600? I forget. Thanks
/*
http://www.instructables.com/id/Send-and-Receive-MIDI-with-Arduino/?ALLSTEPS
ADXL3xx
Reads an Analog Devices ADXL3xx accelerometer and communicates the
acceleration to the computer. The pins used are designed to be easily
compatible with the breakout boards from Sparkfun, available from:
http://www.sparkfun.com/commerce/categories.php?c=80
http://www.arduino.cc/en/Tutorial/ADXL3xx
The circuit:
analog 0: accelerometer self test
analog 1: z-axis
analog 2: y-axis
analog 3: x-axis
analog 4: ground
analog 5: vcc
created 2 Jul 2008
by David A. Mellis
modified 30 Aug 2011
by Tom Igoe
This example code is in the public domain.
*/
int control = 176; //10110000 in binary
int controller = 43;
int control2 = 176; //10110001 in binary
int controller2 = 42;
int control3 = 176; //10110001 in binary
int controller3 = 41;
// these constants describe the pins. They won't change:
const int groundpin = 18; // analog input pin 4 -- ground
const int powerpin = 19; // analog input pin 5 -- voltage
const int xpin = A3; // x-axis of the accelerometer
const int ypin = A2; // y-axis
const int zpin = A1; // z-axis (only on 3-axis models)
void setup()
{
// initialize the serial communications:
Serial.begin(31250);
// Provide ground and power by using the analog inputs as normal
// digital pins. This makes it possible to directly connect the
// breakout board to the Arduino. If you use the normal 5V and
// GND pins on the Arduino, you can remove these lines.
pinMode(groundpin, OUTPUT);
pinMode(powerpin, OUTPUT);
digitalWrite(groundpin, LOW);
digitalWrite(powerpin, HIGH);
}
void loop()
{
int x = analogRead(xpin);
// print the sensor values:
int value = map(x,480,530,0,127);
MIDImessage(control, controller, value);//turn note on
delay(100);
int y = analogRead(ypin);
// print the sensor values:
int value2 = map(y,479,531,0,127);
/MIDImessage(control2, controller2, value2);//turn note on
delay(100);
int z = analogRead(zpin);
// print the sensor values:
int value3 = map(z,478,532,0,127);
MIDImessage(control3, controller3, value3);//turn note on
delay(100);
}
//send MIDI message
void MIDImessage(int command, int MIDInote, int MIDIvelocity) {
Serial.write(command);//send note on or note off command
Serial.write(MIDInote);//send pitch data
Serial.write(MIDIvelocity);//send velocity data
}
