Pages: [1] 2   Go Down
Author Topic: New to Arduino  (Read 1045 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello I am new to Arduino and I need some help.

I get the error message : sketch_feb12a.ino: In function 'void loop()':
sketch_feb12a:34: error: expected `)' before ';' token
sketch_feb12a:34: error: expected `;' before ')' token
sketch_feb12a:41: error: expected `)' before ';' token
sketch_feb12a:41: error: expected `;' before ')' token
sketch_feb12a:48: error: expected `)' before ';' token
sketch_feb12a:48: error: expected `;' before ')' token
sketch_feb12a:55: error: expected `)' before ';' token
sketch_feb12a:55: error: expected `;' before ')' token


to the following code:

int timer = 1000;          
int i = 1;

void setup()
 {  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++)  
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++)  
    for (int thisPin3 = 24; thisPin3 < 38; thisPin3++)  
    for (int thisPin4 = 37; thisPin4 < 43; thisPin4++)  
 {
    pinMode(thisPin1, OUTPUT);  
    pinMode(thisPin2, OUTPUT);
    pinMode(thisPin3, OUTPUT);
    pinMode(thisPin4, OUTPUT);
    pinMode(51, OUTPUT);
    pinMode(52, OUTPUT);
    pinMode(53, OUTPUT);
}}


void loop()
 {  while (i<2) {i++;
 {  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++)  
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++)
    for (int thisPin3 = 24; thisPin3 < 38; thisPin3++)  
    for (int thisPin4 = 37; thisPin4 < 43; thisPin4++)  
   {
    digitalWrite(52, HIGH);
    delay(3000);
    digitalWrite(52, LOW);
 
    digitalWrite(thisPin1, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53; LOW);
    delay(timer);
    digitalWrite(thisPin1, LOW);
 
    digitalWrite(thisPin2, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53; LOW);
    delay(timer);
    digitalWrite(thisPin2, LOW);

    digitalWrite(thisPin3, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53; LOW);
    delay(timer);
    digitalWrite(thisPin3, LOW);

    digitalWrite(thisPin4, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53; LOW);
    delay(timer);
    digitalWrite(thisPin4, LOW);
}}}}


I can not find the problem.

Thanks for your help!!!
#
S
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25770
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you tell us what you're trying to do?
I can't really see a reason for that degree of loop nesting.

Code:
digitalWrite(53; LOW);
Look again.
« Last Edit: February 12, 2013, 05:10:02 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to run 4 rows of led lamps.
Each led should light up for 1 second and for each led a photo should be taken and i want to control the shutter of the camera differently at each row.

THANK YOU!

S
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

post your code with using the code tag function ok btw your code, you are using all your pin in maybe a mega i think
you just use ; in what should be ,
Code:
int timer = 1000;          
int i = 1;

void setup()
 {  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++)  
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++)  
    for (int thisPin3 = 24; thisPin3 < 38; thisPin3++)  
    for (int thisPin4 = 37; thisPin4 < 43; thisPin4++)  
 {
    pinMode(thisPin1, OUTPUT);  
    pinMode(thisPin2, OUTPUT);
    pinMode(thisPin3, OUTPUT);
    pinMode(thisPin4, OUTPUT);
    pinMode(51, OUTPUT);
    pinMode(52, OUTPUT);
    pinMode(53, OUTPUT);
}}


void loop()
 {  while (i<2) {i++;
 {  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++)  
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++)
    for (int thisPin3 = 24; thisPin3 < 38; thisPin3++)  
    for (int thisPin4 = 37; thisPin4 < 43; thisPin4++)  
   {
    digitalWrite(52, HIGH);
    delay(3000);
    digitalWrite(52, LOW);
 
    digitalWrite(thisPin1, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53, LOW);
    delay(timer);
    digitalWrite(thisPin1, LOW);
 
    digitalWrite(thisPin2, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53, LOW);
    delay(timer);
    digitalWrite(thisPin2, LOW);

    digitalWrite(thisPin3, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53, LOW);
    delay(timer);
    digitalWrite(thisPin3, LOW);

    digitalWrite(thisPin4, HIGH);
    digitalWrite(53, HIGH);
    delay(100);
    digitalWrite(53, LOW);
    delay(timer);
    digitalWrite(thisPin4, LOW);
}}}}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes. I am using a Mega Arduino.

Sorry, I did not understand what I should change.

Thanks a lot for your help!!!

S

* sketch_feb12a.ino (1.44 KB - downloaded 8 times.)
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The errors are being caused by lines like this
Code:
digitalWrite(53; LOW);
I am sure that you can see what is wrong  Using the Tools/Autotidy in the IDE made them stand out immediately, and the error line is highlighted by the compiler anyway.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i gave you the edited version ....
Logged

Malaysia
Offline Offline
Sr. Member
****
Karma: 7
Posts: 393
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
int timer = 1000;           
int i = 1;

void setup()

  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++) 
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++) 
      for (int thisPin3 = 24; thisPin3 < 38; thisPin3++) 
        for (int thisPin4 = 37; thisPin4 < 43; thisPin4++) 
        {
          pinMode(thisPin1, OUTPUT); 
          pinMode(thisPin2, OUTPUT);
          pinMode(thisPin3, OUTPUT);
          pinMode(thisPin4, OUTPUT);
          pinMode(51, OUTPUT);
          pinMode(52, OUTPUT);
          pinMode(53, OUTPUT);
        }
}


void loop()

  while (i<2) {
    i++;
    { 
      for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++) 
        for (int thisPin2 = 13; thisPin2 < 25; thisPin2++)
          for (int thisPin3 = 24; thisPin3 < 38; thisPin3++) 
            for (int thisPin4 = 37; thisPin4 < 43; thisPin4++) 
            {
              digitalWrite(52, HIGH);
              delay(3000);
              digitalWrite(52, LOW);

              digitalWrite(thisPin1, HIGH);
              digitalWrite(53, HIGH);
              delay(100);
              digitalWrite(53, LOW);
              delay(timer);
              digitalWrite(thisPin1, LOW);

              digitalWrite(thisPin2, HIGH);
              digitalWrite(53, HIGH);
              delay(100);
              digitalWrite(53, LOW);
              delay(timer);
              digitalWrite(thisPin2, LOW);

              digitalWrite(thisPin3, HIGH);
              digitalWrite(53, HIGH);
              delay(100);
              digitalWrite(53, LOW);
              delay(timer);
              digitalWrite(thisPin3, LOW);

              digitalWrite(thisPin4, HIGH);
              digitalWrite(53, HIGH);
              delay(100);
              digitalWrite(53, LOW);
              delay(timer);
              digitalWrite(thisPin4, LOW);
            }
    }
  }
}
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, I see. Thank you very much. It was highlighted, but i did not see the error.

S
Logged

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How many for loops are there in this code ?
Code:
    for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++) 
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++) 
    for (int thisPin3 = 24; thisPin3 < 38; thisPin3++) 
    for (int thisPin4 = 37; thisPin4 < 43; thisPin4++) 
 {
    pinMode(thisPin1, OUTPUT); 
    pinMode(thisPin2, OUTPUT);
    pinMode(thisPin3, OUTPUT);
    pinMode(thisPin4, OUTPUT);
    pinMode(51, OUTPUT);
    pinMode(52, OUTPUT);
    pinMode(53, OUTPUT);
}
Answers from the OP only, please.
Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I do have four rows of leds. And the shutter has to be controlled different at every row.
Is the code wrong? There is no more error code.

Thanks,

S
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25770
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There is no more error code
That only means that the program is syntactically correct, and that the compiler has generated code for the code as written.
It does not necessarily mean that the code will  do what you intended.

Does the code do what you intended?
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

East Anglia (UK)
Online Online
Faraday Member
**
Karma: 109
Posts: 4066
May all of your blinks be without delay()
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The code is not exaclty wrong, more that it is unusual and unnecessary.
Try this, which as you will see is derived from your code.
Code:
void setup()
{
  int counter =1;
  Serial.begin(9600);

  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++) 
    for (int thisPin2 = 13; thisPin2 < 25; thisPin2++) 
      for (int thisPin3 = 24; thisPin3 < 38; thisPin3++) 
        for (int thisPin4 = 37; thisPin4 < 43; thisPin4++) 
        {
          counter++;
        }
  Serial.println(counter);
}

void loop() {}
You may be surprised by the number of for loops that have been run. Explain in simple terms what you want those for loops to do.

Logged

Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

Offline Offline
Newbie
*
Karma: 0
Posts: 13
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to run 4 rows of leds and to every led i want to take a picture. And the shutter time should be different in every row.
Anyway. My code does not work properly.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My code does not work properly.
Because it is crap, as others have tried to point out.

If you were to use curly braces for every for loop, you'd see that. It is the nesting of the for loops that is wrong.

This is what you want:
Code:
  for (int thisPin1 = 1;  thisPin1 < 13; thisPin1++)
  {
     pinMode(thisPin1, OUTPUT);
  }
  for (int thisPin2 = 13; thisPin2 < 25; thisPin2++) 
  {
     pinMode(thisPin2, OUTPUT);
  }
  for (int thisPin3 = 24; thisPin3 < 38; thisPin3++) 
  {
     pinMode(thisPin3, OUTPUT);
  }
  for (int thisPin4 = 37; thisPin4 < 43; thisPin4++) 
  {
     pinMode(thisPin4, OUTPUT);
  }

Now, what is the loop() function supposed to do? The nested loops there are probably wrong, too.
Logged

Pages: [1] 2   Go Up
Jump to: