Does this code look right?

How does this code look? Its supposed to run multiple PIEZO's and send the data to my serial program.

//###############################################
//VARIABLES
//###############################################
const int numOfAnalogs = 3; //Change the integer to incorporate the amount of analog inputs you use.
int midiChannel = 9;
int outPin = 13; // the number of the output pin, main LED
int analogSmooth = 2; // Amount of change needed to send control change...
int lastAnalogArray[numOfAnalogs];
int reading[numOfAnalogs];
//###############################################
//END OF VARIABLES
//###############################################
void setup()
{
Serial.begin(9600);
}

void loop()
{
for (int i = 0; i<numOfAnalogs; i++) {
reading = analogRead(i)/8; // change 0-1024 into 0-127
if (abs(reading_-lastAnalogArray*) > analogSmooth) {_
lastAnalogArray _= reading;
sendToSerial(i,reading);
}
}
}
void sendToSerial(byte pin, byte velocity) {
digitalWrite(outPin,HIGH); // indicate we're sending MIDI data*

* Serial.print(pin, BYTE);
Serial.print(velocity, BYTE);
digitalWrite(outPin,LOW); // indicate we're sending MIDI data*

}_

const int numOfAnalogs = 3; //Change the integer to incorporate the amount of analog inputs you use.

It is usually a good idea to uppercase the constants, to avoid confusion with variables. No big deal here, but this may be confusing on bigger projects. So you'd better use :

#define NUM_OF_ANALOGS 3

reading = analogRead(i)/8; // change 0-1024 into 0-127
[/quote]
Arduino provides the map() function to do such things. Assigning the result of a division to an integer may (will :slight_smile: ) lead to a loss of precision.
T.

You are correct! semester one revision here i go! :stuck_out_tongue: