I am a complete newby to Arduino and have struck a problem! Any advice as to where I am going wrong.
Thank you
GB
Welcome to the forum
Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'
Use code tags (the </> icon above the compose window) to make it easier to read and copy for examination
What is that semicolon in single quotes doing in from of the setup() function definition ?
Hello didi99
You may start with the IDE examples to learn how the sketches are coded and organizied.
Have a nice day and enjoy coding in C++.
WOW!!!
Thank you, will study this!!
The semi colon etc was my attempt to rectify the error statement! "Expected ',' or ';' before ';' " Which I did not understand!
GB
Please post your full sketch that caused the error originally and use code tags when you do
What is actually wrong is that the semicolon (not in quotes) is missing from the declaration of waitTime
Thank you Paul
try the code below and remember "punctuation and capitalisation is important"
int pin2=2;
int pin3=3;
int pin4=4;
int pin5=5;
int waitTime=1000;
void setup(){
// put your setup code here, to run once
pinMode(pin2,OUTPUT);
pinMode(pin3,OUTPUT);
pinMode(pin4,OUTPUT);
pinMode(pin5,OUTPUT);
delay(waitTime);
}
void loop() {
// put your main code here, to run repeatedly:
}
When it told you it expected ';' before void setup, it meant to put ; (no ') at the end of waitTime=1000. Notice how the variables above it have a semicolon but waitTime doesn't?
Then when you literally added ';' instead of ; right before void setup it confused the compiler further.
So it should have been:
int waitTime = 1000;
void setup() {
not:
int waitTime = 1000
void setup() {
and not:
int waitTime = 1000
';' void setup() {
Admirable, but not a good idea.
First, this is no area for guess work.
Use example code that works and read: I mean put your finger on it and look very closely as you go through it, to develop an idea of how things are expressed, and how algorithms become code.
Second, and sadly, the compiler is good at getting things right, but the error messages can be hard to decipher and interpret, if not misleading or spurious.
Lastly, I recommend that you go to the IDE preferences and turn up all compiler warnings and error reporting to the maximum available.
You’ll get a crap ton more output from the compilation process, but you will also be advised about syntax that, while legal, may not be express what you want or think it is.
And C/C++ will def let you say things you don’t mean, if they are legal. It is famously said that it is a powerful tool that will stand by while you shoot yourself in the foot.
Not trying to scare you, just plain true. A line of code that ends up doing nothing at all? Fine. You might get a warning, if you’ve asked, and… you might not.
a7
Thanks all, I am still trying to absorb it all!!
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.