Pages: [1]   Go Down
Author Topic: How to use the function "DO WHILE"  (Read 842 times)
0 Members and 3 Guests are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone
I'm just started to use Arduino and I have some problems with function "Do  While". I got some examples in the support page but the error persist .
Basically I'm trying to do a Led matrix change the draw inside during  the time without use a CI.
The error that IDE returns to me is described bellow:

Painel_de_sinaliza__o:42: error: expected unqualified-id before 'do'
Painel_de_sinaliza__o:167: error: expected unqualified-id before 'while'
Painel_de_sinaliza__o:293: error: expected unqualified-id before 'while'


Can anyone help me?
Thanks
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 106
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can anyone help me?

Hi- you will need to post the sketch. I'm guessing you have a bracket or a ; missing, but we can't know until we see the code.

Just copy paste it, select, and hit the # icon above the  smiley-wink smiley-sweat smilies, so that....

Code:
the code
looks
{
like this
}
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Offline Offline
Edison Member
*
Karma: 41
Posts: 1380
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://crasseux.com/books/ctutorial/do...while.html
Logged

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

Okay sorry see the code bellow:
 
Code:
//Painel de advertência com LED
  int tempo=0;
  const int col13=9;
  const int col3=3;
  const int col4=2;
  const int col10=12;
  const int col6=15;
  const int col11=11;
  const int col15=7;
  const int col16=6;
  const int row9=13;
  const int row14=8;
  const int row8=17;
  const int row12=10;
  const int row1=5;
  const int row7=16;
  const int row2=4;
  const int row5=14; 

  void setup(){

  pinMode (col13, OUTPUT);
  pinMode (col3, OUTPUT);
  pinMode (col4, OUTPUT);
  pinMode (col10, OUTPUT);
  pinMode (col6, OUTPUT);
  pinMode (col11, OUTPUT);
  pinMode (col15, OUTPUT);
  pinMode (col16, OUTPUT);
  pinMode (row9, OUTPUT);
  pinMode (row14, OUTPUT);
  pinMode (row8, OUTPUT);
  pinMode (row12, OUTPUT);
  pinMode (row1, OUTPUT);
  pinMode (row7, OUTPUT);
  pinMode (row2, OUTPUT);
  pinMode (row5, OUTPUT);
  }



do  {


   tempo++
     
   //Linha 1 Estágio 1
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row9, HIGH);
   delay(1);
   digitalWrite(row9, LOW);
   delay(1);
   
   //Linha 2 Estágio 1
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row14, HIGH);
   delay(1);
   digitalWrite(row14, LOW);
   delay(1);
 
   //Linha 3 Estágio 1
 
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row8, HIGH);
   delay(1);
   digitalWrite(row8, LOW);
   delay(1);
   
   //Linha 4 Estágio 1
 
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, LOW);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, LOW);
   digitalWrite(col16, HIGH);
   digitalWrite(row12, HIGH);
   delay(1);
   digitalWrite(row12, LOW);
   delay(1);
   
   //Linha 5 Estágio 1
 
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, LOW);
   digitalWrite(col3, LOW);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, LOW);
   digitalWrite(col16, LOW);
   digitalWrite(row1, HIGH);
   delay(1);
   digitalWrite(row1, LOW);
   delay(1);
   
   //Linha 6 Estágio 1
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row7, HIGH);
   delay(1);
   digitalWrite(row7, LOW);
   delay(1);
   
   //Linha 7 Estágio 1
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row2, HIGH);
   delay(1);
   digitalWrite(row2, LOW);
   delay(1);
   
   //Linha 8 Estágio 1
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row5, HIGH);
   delay(1);
   digitalWrite(row5, LOW);
   delay(1);
 
} while (tempo<63)
 
do
   {
   
      tempo=tempo+1
   //Linha 1 Estágio 2
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row9, HIGH);
   delay(1);
   digitalWrite(row9, LOW);
   delay(1);
   
   //Linha 2 Estágio 2
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row14, HIGH);
   delay(1);
   digitalWrite(row14, LOW);
   delay(1);
 
   //Linha 3 Estágio 2
 
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, LOW);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, LOW);
   digitalWrite(col16, HIGH);
   digitalWrite(row8, HIGH);
   delay(1);
   digitalWrite(row8, LOW);
   delay(1);
   
   //Linha 4 Estágio 2
 
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, LOW);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, LOW);
   digitalWrite(row12, LOW);
   delay(1);
   digitalWrite(row12, LOW);
   delay(1);
   
   //Linha 5 Estágio 2
 
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, LOW);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, LOW);
   digitalWrite(row1, HIGH);
   delay(1);
   digitalWrite(row1, LOW);
   delay(1);
   
   //Linha 6 Estágio 2
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, LOW);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, LOW);
   digitalWrite(col16, HIGH);
   digitalWrite(row7, HIGH);
   delay(1);
   digitalWrite(row7, LOW);
   delay(1);
   
   //Linha 7 Estágio 2
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, LOW);
   digitalWrite(col11, LOW);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row2, HIGH);
   delay(1);
   digitalWrite(row2, LOW);
   delay(1);
   
   //Linha 8 Estágio 2
   
   digitalWrite(col6, LOW);
   digitalWrite(col10, LOW);
   digitalWrite(col13, HIGH);
   digitalWrite(col3, HIGH);
   digitalWrite(col4, HIGH);
   digitalWrite(col11, HIGH);
   digitalWrite(col15, HIGH);
   digitalWrite(col16, HIGH);
   digitalWrite(row5, HIGH);
   delay(1);
   digitalWrite(row5, LOW);
   delay(1);
 
    } while (tempo>63)
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 106
Posts: 4702
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You sketch has no loop(){} section.

This code Bare Minimum doesn't do anything but it's the minimum structure required to compile.
Logged

The Elders of the Internet know who I am
I'm on LinkedIn: http://www.linkedin.com/in/jimbrownza

Pages: [1]   Go Up
Jump to: