I am trying to run this code and I keep getting the following error message at the: void loop() {
a function-definition is not allowed here before '{'token
Could some explain what is wrong with my code.
Thank you.
/*
Sensor Reader
Language: Arduino
Reads two analog inputs and two digital inputs and Outputs their values.
Connections: analog sensors on analog input pins 0 and 1
switches on digital I/O pins 2 and 3.
*/
int leftSensor = 0;
int rightSensor =1;
int resetButton =2;
int serveButton =3 ;
int leftValue =0;
int rightValue =0;
int reset = 0;
int serve = 0;
void setup() {
//configure the serial connector
Serial.begin(9690);
//config digital inputs:
pinMode(resetButton, INPUT);
pinMode(serveButton, INPUT);
while (Serial.available() <= 0) {
Serial.print(10,BYTE); //send a return character
delay(300);
}
void loop() {
//check to see whether there is a byte available
//to read in the serial buffer
if (Serial.available() >0) {
//read the serial buffer: You dont care about the value
//of the incoming bytes just that one was sent.
int inByte = Serial.read();
leftValue = analogRead(leftSensor);
rightValue = analogRead(rightSensor);
//read the digital sensor:
reset = digitalRead(resetButton);
serve = digitalRead(serveButton);
//print the results:
Serial.print(leftValue, DEC);
Serial.print(",");
Serial.print(rightValue, DEC);
Serial.print(",");
Serial.print(reset, DEC);
Serial.print(",");
//print the last sensor with a println() so that
//each set of 4 reading prints on a line by itself:
Serial.println(serve,DEC);
}
}