Go Down

Topic: Arduino Coding Serial Error (Read 929 times) previous topic - next topic

SkyCrafter

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
Code: [Select]
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
Code: [Select]
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  :smiley-lol:
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

GrooveFlotilla

Code: [Select]
int incomingByte = Serial.read();Not in a function.
Oops
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

SkyCrafter

I know, I need it to be global. not just the one function.
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

GrooveFlotilla

#3
Mar 22, 2018, 10:34 pm Last Edit: Mar 22, 2018, 10:43 pm by GrooveFlotilla
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)
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

SkyCrafter

#4
Mar 22, 2018, 10:49 pm Last Edit: Mar 22, 2018, 10:51 pm by SkyCrafter
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...
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

GrooveFlotilla

#5
Mar 22, 2018, 10:51 pm Last Edit: Mar 22, 2018, 10:58 pm by GrooveFlotilla
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.

Quote
Also, did you read my first post? that IS all my code..
I assumed you were being economical with the truth to avoid embarrassment.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

SkyCrafter

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.
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

GrooveFlotilla

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

Back to you.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

Robin2

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

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

SkyCrafter

Robin2 Thank you for real info
Props to you, +1 Karma
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

GrooveFlotilla

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?
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

SkyCrafter

were you actually uploading it? what programmer? what board?
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

GrooveFlotilla

#12
Mar 23, 2018, 03:43 pm Last Edit: Mar 23, 2018, 03:44 pm by GrooveFlotilla
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.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

GrooveFlotilla

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.
Some people are like Slinkies.

Not really good for anything, but they bring a smile to your face when pushed down the stairs.

SkyCrafter

no?
im going to use a mega for this project. stop posting on this.
Some people are just dinguses. Some people are just geniuses. I'm a dingus. It's fun to push dinguses down the stairs. It's fun to push yourself down the stairs.

Go Up