So, i'm just sitting here and trying to make a code to access the controls for my project, and the serial isn't being declared. I am beginning the serial in the setup and using serial printing in a function.
Code: (all my code so far, just started) Error Line Bolded
void setup() {
Serial.begin(115200);
passcodeCheck();
}
const int passcode = 1324;
int access = 0;
int incomingByte = Serial.read();
void passcodeCheck() {
[b]Serial.print("Enter Passcode: ");[/b]
Serial.print(incomingByte);
}
Error Message
DestroyerShip:17: error: 'Serial' was not declared in this scope
Serial.print("Enter Passcode: ");
^
exit status 1
'Serial' was not declared in this scope
I don't know, I thought it would be executed each time I call the variable? Or is there another way to receive multiple characters from the serial monitor?
Also, did you read my first post? that IS all my code...
Read this. the forum guidelines on how to post a programming question. then read the whole thing as you have CLEARLY not read it...
If you get an error, post the error (copy and paste). Not just "I got an error". With coding problems, if possible post a "minimal" sketch that demonstrates the problem - not hundreds of lines of code. <----- read this back to me!
If you have debugging information in your sketch, post your debugging displays.
Just for $hits and giggles, I took the code from the original post, removed the [b][/b] tags, and pasted it into the IDE.
Try as hard as I can, I can't get it to produce the error message @SkyCrafter claims for it.
All I get is the expected "undefined reference to `loop' "
How can you expect to upload something that does not and cannot compile?
What difference would an un-invoked programmer make to the outcome of a failed compilation?
(Anyway, aren't you the one who is supposed to furnish all that detail?)
Please, start making some sense.
If you take the code posted above, and compile it for a Mega, you should see this:
Arduino: 1.6.12 (Linux), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
/tmp/ccNfzOpl.ltrans0.ltrans.o: In function `main':
ccNfzOpl.ltrans0.o:(.text.startup+0x202): undefined reference to `loop'
collect2: error: ld returned 1 exit status
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
If you put in a dummy loop
void setup() {
Serial.begin(115200);
passcodeCheck();
}
const int passcode = 1324;
int access = 0;
int incomingByte = Serial.read();
void passcodeCheck() {
Serial.print("Enter Passcode: ");
Serial.print(incomingByte);
}
void loop (){} // <<< I ADDED THIS
and compiled it, again, for a Mega, you should see this message
Sketch uses 2,090 bytes (0%) of program storage space. Maximum is 253,952 bytes.
Global variables use 204 bytes (2%) of dynamic memory, leaving 7,988 bytes for local variables. Maximum is 8,192 bytes.
.
The only way I can see that you could get a error for Serial not being defined, would be if you compiled the code for a processor that doesn't have a UART.