Go Down

Topic: Can't program basic circuits! (Read 397 times) previous topic - next topic

Kparv

Hi
So, I just got a basic Arduino Uno board with some example circuits in the guide. Just to get used to programming, I have built a basic blinking LED connected to pin 13.
However, whenever I try to upload code, it will not work.
error: expected constructor, destructor, or type conversion before '(' token
is the error message. This comes up even when uploading simple code like
pinMode(13,OUTPUT);

I know if I can fix this I will quickly get to grips with programming, but just can't fix this error!
Please Help!!

UKHeliBob

Post your whole program otherwise we are just guessing at what the problem might be
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Nick Gammon

How to use this forum

Post your code, there will be something wrong there.
http://www.gammon.com.au/electronics

Kparv

My code:

void setup()
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
delay(1000);
digitalWrite(13, LOW);
delay(1000);


I know it's basic but its just to get me started.

KeithRB

You need to surround your code with {}.

Look at the examples!

Kparv

Still wont work!!
sketch_mar07d:6: error: expected constructor, destructor, or type conversion before '(' token

Really confused?!?!?!

Kparv

#6
Mar 07, 2013, 10:18 pm Last Edit: Mar 07, 2013, 10:23 pm by Kparv Reason: 1
sketch_mar07d:6: error: expected declaration before '}' token
Code: [Select]

{void setup()
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);}
delay(1000);
digitalWrite(13, LOW);
delay(1000);}
[code/]

Nick Gammon

Please edit your post, select the code, and put it between [code] ... [/code] tags.

You can do that by hitting the # button above the posting area.

This was explained here: How to use this forum


Code: [Select]

void setup()
{
  pinMode(13, OUTPUT);
  digitalWrite(13, HIGH);
  delay(1000);
  digitalWrite(13, LOW);
  delay(1000);
}


Look at the examples. Don't just leave stuff out or put braces wherever you feel like it.
http://www.gammon.com.au/electronics

Go Up