expected initializer before 'do'

Hello,

I’m a very beginner an try to get a loop programmed. Here is the code:

void setup() {
// initialize digital pin 13 as an output.
pinMode(13, OUTPUT);
// setzen Variable
int intDauer = 50;
}

// the loop function runs over and over again forever
void loop()

do
// while (intDauer > 2);
{

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(13, LOW); // turn the LED off by making the voltage LOW
delay(500); // wait for a second

intDauer-- // reduziert Variable um 1
} while (intDauer >2)

I alsways get the message:

expected initializer before ‘do’

who can help me?

Kind regards
blooybeginner

Edit your post and put the code inside the code tags please. See the how to use this forum sticky post at the top of the forum listing for details.

You forgot the opening bracket of your loop() function body.

This is the code:

void setup() { // initialize digital pin 13 as an output. pinMode(13, OUTPUT); // setzen Variable int intDauer = 50; }

// the loop function runs over and over again forever void loop()

do // while (intDauer > 2); {

digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(13, LOW); // turn the LED off by making the voltage LOW delay(500); // wait for a second

intDauer-- // reduziert Variable um 1 } while (intDauer >2)

kind regards

You have STILL forgotten the opening bracket of your loop() function body.

johnwasser: You have STILL forgotten the opening bracket of your loop() function body.

And the code tags.

Delta_G: And the code tags.

You can't really expect more from a bloody-beginner.

@bloody-beginner: Please edit your post, select the code, and put it between [code][/code] tags.

You can do that by hitting the “Code” icon above the posting area. It is the first icon, with the symbol: </>

How to use this forum

Hello

I’m sitting a trying to learn a litte of Arduiono programming. It seem not to be simple.

I get the message:

‘else’ without a previous ‘if’

in the following code

void setup() {
  // initialize digital pin 13 as an output.
  pinMode(13, OUTPUT);
  // setzen Variable
  int intDauer = 50;
}

// the loop function runs over and over again forever
void loop() 

{
  int intDauer = 0;

if (intDauer<2000);
{ 
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(intDauer);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(2000);               // wait for a second
  intDauer-200;
}
else
{
  digitalWrite(13, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(intDauer);              // wait for a second
  digitalWrite(13, LOW);    // turn the LED off by making the voltage LOW
  delay(2000);               // wait for a second
  intDauer+200;
}
}

can somebody improve the code so that it works?

I would like to get the LED blinking longer, and than shorter.

Kind regards and thank you for your help a bloody beginner.

if (intDauer<2000);What’s that semi-colon doing there ?

It is not that hard, you're on the right track. But just like with every language (English, Dutch, Spanish, C++, PHP) punctuation can make or break the meaning of a sentence (or line of code). So devil is in the details ;)