Go Down

Topic: it expects ; before void, but when i put it there it still expects it (Read 702 times) previous topic - next topic

Qwerzer23

i don't know if i am doing something wrong but this is happening to me and its getting really frustrating, please fix or if i'm just being bad then please tell me what to do

AWOL

You need to explain your problem and post your code; we're not psychic.

Qwerzer23

here's the code

int ledpin13 = 13
void setup() {
   
}

void loop() {
    ;digitalWrite(ledpin13, HIGH)
    ;delay(100)
    ;digitalWrite(ledpin13, LOW)
    ;delay(100)
}

i'm trying to do a simple led setup but it expects ;void setup even if usually it doesnt, and if i put ; there it still wants me to put ;.

By the way im using arduino create on a chromebook

AWOL

Does that code look anything like any of the many examples provided in the IDE?

You don't have to work in the dark, you know - there are many examples of code out there, even "blink with delay".

Qwerzer23

thats exactly the one i used and modified, only problem is when i add the int it wants the semicolon before void setup, i add the semicolon but it still wants a semicolon.

i attached a screenshot

AWOL

Quote
thats exactly the one i used and modified
Please point out where in the example code you see anything like this
Code: [Select]
   ;digitalWrite(ledpin13, HIGH)

Also, if you're going to write to a pin, it is usually a good idea to make it an output first, otherwise you're just waggling the pullup resistor on and off.

Qwerzer23

making ledpin13 an output didnt fix my problem. i do thank you for telling me to make it an output as im kinda new, but the problem is with the "void setup() {}" it says that it requires a semicolon before void, when i add the semicolon it still wants me to add a semicolon, even if ive done that

AWOL

Code: [Select]

const byte ledpin = 13;

void setup() {
    pinMode (ledpin, OUTPUT);
}

void loop() {
    digitalWrite(ledpin, HIGH);
    delay(100);
    digitalWrite(ledpin, LOW);
    delay(100);
}


Can you see the differences?

Qwerzer23


AWOL

You can't see that semicolons are at the end of the lines, not the beginning? :o

Qwerzer23

ok so yes i didnt see that, but my arduino create says before and if you look at the screenshot i sent a few replies ago you would see it say "expected ',' or ';' before 'void'. and you didnt add any ; after or before void right? but now a new problem is that i added semicolons both before and after void, it wanted that with 'setup' aswell and now it says setup does not name a type


im attaching a screenshot to this reply

AWOL

Quote
im attaching a screenshot to this reply
Why should I waste 123 kB of my mobile data plan, when you could have posted a couple of hundred bytes of text?

Let me ask you again - where have you ever seen code that looks like yours?

Do you think there may be a reason for that?


Here is the code you posted (badly) originally
Code: [Select]
int ledpin13 = 13
void setup() {
   
Can you see that the first line is missing a semicolon?

That semicolon that isn't there syntactically should come before the compiler sees the word "void" (or a whole host of other words).

Qwerzer23

okay so here is the whole code right now, including the ';void; ;setup;' weird semicolons
Code: [Select]
int ledpin13 = 13
;void; ;setup;() {
    ledpin13 = OUTPUT
}

void loop() {
    ;digitalWrite(ledpin13, HIGH);
    ;delay(100);
    ;digitalWrite(ledpin13, LOW);
    ;delay(100);
}

i got it from blink in basics in examples and i tried modifying it, but then it wanted me to add a semicolon before void and then it asked again.

AWOL

Put your sketch away for now, and find yourself a good online C/C++ tutorial.

It looks like you're trying to make up your own syntax.

That never ends well.


Go Up