Arduino Coding Serial Error

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

Thanks :grinning:

int incomingByte = Serial.read();Not in a function.
Oops

I know, I need it to be global. not just the one function.

When do you think the Serial.read is going to be executed?
Is that a good idea?

(In return for you not posting all your code, I'm not posting complete answers. Hope that's OK with you)

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...

You call functions.
You do not call variables (unless the variable is a function pointer)

The only way to receive multiple characters is to call, directly or indirectly, Serial.read.

Also, did you read my first post? that IS all my code..

I assumed you were being economical with the truth to avoid embarrassment.

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.

A minimal sketch will have a setup function, and a loop function.

Back to you.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

Robin2 Thank you for real info
Props to you, +1 Karma

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' "

I wonder why that is?

were you actually uploading it? what programmer? what board?

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.

Ha Ha Ha Ha

I just looked at some of your other posts, like "Error while burning bootloader to attiny85".
I assume this is related to the same project.

Ha Ha Ha Ha.

no?
im going to use a mega for this project. stop posting on this.

@SkyCrafter, please post your full code.
It's impossible to help you if you don't help us!!

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.

OOF.

SkyCrafter:
OOF.

Out of focus ?

SkyCrafter:
OOF.

Did you have something to add, or are you just channeling a Gaston Lagaffe comic?