Pages: [1]   Go Down
Author Topic: "Error Message" Interpretation  (Read 2202 times)
0 Members and 1 Guest are viewing this topic.
New Zealand
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Charlie Forshaw
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi folks, I am banging my head against a brick wall trying to interpret "error messages". Is there a straight forward dictionary of "error messages"? in my attempts at searching my "error messages" I get lots of good examples of other peoples projects with the same "error message" as mine, but does not help me as the answers are not relevant to my project. I am trying to "stop" or "end" my sketch after one run and was advised to use " void loop() { } ."  each attempt gave error message, " redefinition of void loop" or "unqualified-id", What exactly do they mean? Help would be much appreciated. Chez7.
Logged

California
Offline Offline
Newbie
*
Karma: 0
Posts: 45
What was that?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Put your main code in void setup() and then put nothing in void loop(). With nothing inside of void loop there will be no repeating code and it just loops forever.
Logged

Inconveniencing electrons one drop at a time

New Zealand
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Charlie Forshaw
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks ElectricWater, will try that Chez7.
Logged

New Zealand
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Charlie Forshaw
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Electric Water, Tried your suggestion, not working. When you say void loop() "put nothing in it " I assume you mean type "void loop() { } ". I have tried this where void loop currently sits, no go, I have shifted it to end of sketch, still no go. Where am I going wrong. Im sure theres a simple solution, Cheers
                                                                                                                                     Chez7.



//Example 01 : Blinking LED

# define LED 13  // LED connected to
                //digital pin 13
               
void setup ()

{
 pinMode( LED, OUTPUT ) ;   // Sets the digital pin as output.
 
}

 void loop()
{
  digitalWrite( LED, HIGH);  //Turn the Led on
 
  delay(4000);               // Waits for
 
  digitalWrite(LED, LOW);    // Turns led off
 
  delay (4000) ;             // Waits for 
 
   digitalWrite( LED, HIGH);  //Turn the Led on
   
   delay(500);               // Waits for
 
 digitalWrite(LED, LOW);    // Turns led off
 
  delay(500);               // Waits for
 
}
 

Logged

0
Offline Offline
Sr. Member
****
Karma: 4
Posts: 329
KC4MM
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There are a couple of ways to do what you want.
One way is to put all your code into setup like this:

Code:
void setup ()

{
   pinMode( LED, OUTPUT ) ;   // Sets the digital pin as output.
   digitalWrite( LED, HIGH);  //Turn the Led on
 
  delay(4000);               // Waits for
 
  digitalWrite(LED, LOW);    // Turns led off
 
  delay (4000) ;             // Waits for
 
   digitalWrite( LED, HIGH);  //Turn the Led on
  
   delay(500);               // Waits for
 
 digitalWrite(LED, LOW);    // Turns led off
 
  delay(500);               // Waits for

}

 void loop()
{
 
}

Another way is to add while(1)    or for( ; ; ) at the end of loop. Either of these is always satisfied so the code will hang at those lines.

Code:
# define LED 13  // LED connected to
                //digital pin 13
              
void setup ()

{
   pinMode( LED, OUTPUT ) ;   // Sets the digital pin as output.
}

 void loop()
{
   digitalWrite( LED, HIGH);  //Turn the Led on
 
  delay(4000);               // Waits for
 
  digitalWrite(LED, LOW);    // Turns led off
 
  delay (4000) ;             // Waits for
 
   digitalWrite( LED, HIGH);  //Turn the Led on
  
   delay(500);               // Waits for
 
 digitalWrite(LED, LOW);    // Turns led off
 
  delay(500);               // Waits for

  while(1);  // this will loop forever right here
}
 
« Last Edit: May 16, 2011, 08:02:41 pm by RoyK » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8606
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

This compiles just fine (sorry about the crap formatting)

Code:
//Example 01 : Blinking LED

# define LED 13  // LED connected to
                //digital pin 13
               
void setup ()

{
 pinMode( LED, OUTPUT ) ;   // Sets the digital pin as output.
    digitalWrite( LED, HIGH);  //Turn the Led on
 
  delay(4000);               // Waits for
 
  digitalWrite(LED, LOW);    // Turns led off
 
  delay (4000) ;             // Waits for 
 
   digitalWrite( LED, HIGH);  //Turn the Led on
   
   delay(500);               // Waits for
 
 digitalWrite(LED, LOW);    // Turns led off
 
  delay(500);               // Waits for
 
}

 void loop()
{

}

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

New Zealand
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Charlie Forshaw
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, Rob and RoyK, I see now where  I was going wrong, works spot on now. Cheers Chez7
Logged

Seattle, WA
Offline Offline
God Member
*****
Karma: 11
Posts: 673
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi folks, I am banging my head against a brick wall trying to interpret "error messages". Is there a straight forward dictionary of "error messages"? in my attempts at searching my "error messages" I get lots of good examples of other peoples projects with the same "error message" as mine, but does not help me as the answers are not relevant to my project.

Just to touch on the original question...  The canonical solution is in fact to just search for the error message and work out what's happening to other folks.  I originally learned to program before this resource was available, and I'll say it's now MUCH faster to learn new tech because of it.

And then the other solution is to do just as you did -- post to a forum.  Usually it's best to include the actual code causing the error and the actual error you get.
Logged


New Zealand
Offline Offline
Newbie
*
Karma: 0
Posts: 22
Charlie Forshaw
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks, Maniacbug, your advice noted,Chez7
Logged

Pages: [1]   Go Up
Jump to: