Hi,
I am recieving the error mentioned above. Much help is appreciated.
Code starting from loop:
myFile = SD.open("data.txt", FILE_WRITE);
if (myFile) {
myFile.print("");
myFile.println("Start");
myFile.println();
myFile.println("IR Sensor(Analog) Raw:");
myFile.print(IR);
myFile.println("Tiltswitch(Digital) Raw:");
myFile.print(tiltswitch1);
myFile.println("3144 Hall Effect Sensor(Analog) Raw:");
myFile.print(hall);
myFile.println("Light Sensor(Analog) Raw:");
myFile.print(Lightsensor);
myFile.println("Microphone(Analog Raw:");
myFile.print(Microphone);
myFile.println("Microphone(Digital) Raw:");
myFile.print(Microphonedigital);
myFile.println("Flame sensor(Digital) Raw:");
myFile.print(Flamedigital);
myFile.println("LM35 Temerature(Converetd to C):");
myFile.print(LM35temperature)
myFile.println("Reed Switch(Digital) Raw:")
myFile.print(reedswitch);
myFile.println("Hall effect Sensor(Digital) Raw:");
myFile.print(halleffect);
myFile.println("Hall Effect Sensor(Analog) Raw:");
myFile.print(halleffectA);
myFile.println("Temperature Sensor(Digital) Raw:");
myFile.print(TemeratureD);
myFile.close(); // close the file
}
// if the file didn't open, print an error:
else {
Serial.println("error opening test.txt");
}
delay(3000);
Error Code:
In function 'void setup()':
_3:103: error: a function-definition is not allowed here before '{' token
void loop() {
^
_3:137: error: expected '}' at end of input
}
^
exit status 1
a function-definition is not allowed here before '{' token
The error probably lies in the code before loop(). But we can't be sure.
Please post all of your code, using code tags. If you don't know what that means then please read the sticky 'How to use this forum - please read'.
It looks like you have a missing } to close the setup function, that's my guess.
dannable:
The error probably lies in the code before loop(). But we can't be sure.
Please post all of your code, using code tags. If you don't know what that means then please read the sticky 'How to use this forum - please read'.
Yup, I checked through and you are right, I forgot a "}". Thanks very much!
Common compiler errors caused by mismatched brackets:
"does not name a type" or
"expected declaration before"
Usually means you forgot a '{' or put in an extra '}' in the previous function. Since all of the open brackets have been closed, the compiler is looking for further global declarations (variables or functions). If it finds something that looks like executable code instead of a global declaration it emits an error. Count the brackets in the preceding function declaration.
"a function-definition is not allowed here"
Usually means you forgot a '}' or put in an extra '{' in the previous function. Since a set of brackets has not been closed yet the compiler is looking for more code to put in the function. You can't declare a function inside a function so if the compiler finds a function definition it emits an error. Count the brackets in the preceding function declaration.
"expected '}' at end of input"
Usually means you forgot a '}' or put in an extra '{' in the last function in the sketch. Since a set of brackets has not been closed yet, the compiler is looking for more code to put in the function. When it hits the end of the file instead it emits an error. Count the brackets in the last function declaration.