Trouble shooting code

With this code I’m just looking to monitor 5 sensors and obtain the values, mainly looking at the hysteresis of the sensors and seeing if this is something I could use on a larger scale ~ 60 sensors. I’m not great with programming with the Arduino software, used to graphical programming. Anyway I cant get this code to load to the Arduino, do you see any glaring errors or misuse of the code in basic terms or does it need a complete re-write? Again thank you for your time and patience. I pasted the code below: I placed notes to make it easier to understand where I’m heading with it.

// Piezo Start Voltage Read // Read A0-4 set to 100ms for start then adjust if readings are off

void setup() { //start serial at 9600 baud rate (charecters per second) Serial.begin(9600)

;void loop() { //First section Read all analog ports for the 5 flexiforce sensors //Read input on analog pin 0 int flexValue0 = analogRead(A0);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage0 = flexValue0 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Read input on analog pin 1 int flexValue1 = analogRead(A1);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage1 = flexValue1 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Read input on analog pin 2 int flexValue2 = analogRead(A2);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage2 = flexValue2 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Read input on analog pin 3 int flexValue3 = analogRead(A3);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage3 = flexValue3 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Read input on analog pin 4 int flexValue4 = analogRead(A4);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino): float voltage4 = flexValue4 * (5.0 / 1023.0);

// Wait 100 milliseconds or adjust delay(100);

//Print colleceted values from the 5 flexiforce sensors for analog inputs A0-A4

// Print value from A0 Serial.println(voltage0);

// Print value from A1 Serial.println(voltage1);

// Print value from A2 Serial.println(voltage2);

// Print value from A3 Serial.println(voltage3);

// Print value from A4 Serial.println(voltage4);

// Wait 100 milliseconds or adjust delay(100); }

Error message:

Arduino: 1.5.7 (Windows 7), Board: "Arduino Uno"

Voltage_read_5_sensors.ino: In function 'void setup()':
Voltage_read_5_sensors.ino:12:1: error: a function-definition is not allowed here before '{' token
Voltage_read_5_sensors.ino:78:1: error: expected '}' at end of input

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

I placed notes to make it easier to understand where I’m heading with it.

Well, it's impossible to even read that mess. ONE statement per line. Statements NEVER start with a ;.

Why ARE you (trying to) embed loop() in setup()?

Use the enter key to keep your comments and statements to one screen width. Post your code correctly, using code tags (the # icon creates them; you post your code between them).

One of the slowest expressions you can evaluate is division. Floating point division is even worse. So, everywhere you find an expression similar to:

 float voltage0 = flexValue0 * (5.0 / 1023.0);

use something like:

#define SENSORRATIO  0.00488758
// more of your code, then statements like above:

float voltage0 = flexValue0 * SENSORRATIO;
// ...more code...
float voltage1 = flexValue1 * SENSORRATIO;
// ...and so on

It may not make much difference, depending upon how it is used, but it should save at least a few CPU cycles.

Actually I would be very surprised if it saved any cpu cycles at all.
In this case the division would be done by the compiler and not at run time so the code generated would be the same.
Using a #define is a good idea though.

@PhilC: You're right. An optimizing compiler should generate a single constant. A better form for the #define might be:

#define SENSORRATIO  0.00488758      // 0.00488758 = (5.0 / 1023.0)

so they can see where the number came from.

your missing the } required for all your functions... also, comment out lines have to be on a Separate line...eg

int flexValue0;
int flexValue1;

void setup() {
//start serial at 9600 baud rate (charecters per second) RETURN
Serial.begin(9600);
}

void loop() {
//First section Read all analog ports for the 5 flexiforce sensors
//Read input on analog pin 0
flexValue0 = analogRead(A0);

//Convert the analog reading (0-1023, comes from the 10 bit ADC on the Arduino) to Voltage (0-5v comes from the voltage out of the Arduino):
float voltage0 = flexValue0 * (5.0 / 1023.0);
// Wait 100 milliseconds or adjust
delay(100);
//Read input on analog pin 1
flexValue1 = analogRead(A1);
...
}

I'm by no means an expert though, I've only be doing this for 3-4 weeks now, but those are pretty glaring issues.