Hi, Is there somewhere I can go where there is a "dictionary" or explanation of error messages ?.ie, error messages when trying to verify code. thanks, Chaso
Probably not the best list for Arduino..
If you want more details about certain error messages, you can post your code and the error messages.
Hi Codlink,would just the relevent part of the code be sufficient ? eg, while (COLOR!=1 && digitalRead(Button)==HIGH)// This loop is repeated while color is Green or Blue AND button is held down.
{
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LEDR = 6; // Red Led pin 6
int LEDB = 7; // Blue Led pin 7
int LEDGr = 8; // Green Led pin 6
int Button=1;
int COLOR; // variable Color
int Beep;
int PSE; // variable pause
int TME; // Time
int RTME=0; // Reaction Time
void setup()
{ < this " { ", is blinking, with the message "a function - definition is not allowed here before " { " token."
lcd.begin(16, 2);
pinMode(LEDR, OUTPUT);
pinMode(LEDB, OUTPUT);
pinMode(LEDGr, OUTPUT);
pinMode(Button, INPUT);
digitalWrite(LEDR, LOW); // All lights are switched "on".
digitalWrite(LEDB, LOW);
digitalWrite(LEDGr, LOW);
}
Does this make sense. Chaso
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.
I don't see any immediate problems with that. So post all of your code.
Use code tags. Paste your code, highlight it, click the # button.
Chaso:
Hi, Is there somewhere I can go where there is a "dictionary" or explanation of error messages ?
http://gcc.gnu.org/wiki/FAQ#Is_there_a_list_of_GCC_diagnostics.2BAC8-messages.3F
{ // <<<<< REMOVE THIS LINE
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LEDR = 6; // Red Led pin 6
int LEDB = 7; // Blue Led pin 7
int LEDGr = 8; // Green Led pin 6
...
Hi Coding Badly, Tried deleteing that line, made no difference. I think I am making a basic problem. I copy the whole code from the oiginal source, I then paste it into Arduino sketch, BUT, the code is repeated over and over again continuosly !!! Chaso
See reply #3.
Advice taken, here is code.
//After Dinner Reaction Time tester - created by Bertus52x11
//Used a RGB LED with a common Anode (3 Cathodes: R, G, B).
//Therefore, some "digitalwrite" commands may seem ackward: HIGH=off and LOW=on.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int LEDR = 6; // Red Led pin 6
int LEDB = 7; // Blue Led pin 7
int LEDGr = 8; // Green Led pin 6
int Button=1;
int COLOR; // variable Color
int Beep;
int PSE; // variable pause
int TME; // Time
int RTME=0; // Reaction Time
void setup()
{
lcd.begin(16, 2);
pinMode(LEDR, OUTPUT);
pinMode(LEDB, OUTPUT);
pinMode(LEDGr, OUTPUT);
pinMode(Button, INPUT);
digitalWrite(LEDR, LOW); // All lights are switched "on".
digitalWrite(LEDB, LOW);
digitalWrite(LEDGr, LOW);
}
void loop()
{
lcd.clear(); // Clear screen.
lcd.print("Hold Button to");
lcd.setCursor(0,1); // move to second line.
lcd.print("start.");
while (digitalRead(Button)==LOW) // The test does not start until the button is pushed (and held down).
{tone(13,1200,30);
delay(1400);
noTone(13);
}
lcd.clear();
digitalWrite(LEDR, HIGH); // switch off the "start"light.
digitalWrite(LEDB, HIGH);
digitalWrite(LEDGr, HIGH);
randomSeed(analogRead(0)); //Random noise from pin 0
COLOR = random(1,4); // Generate a random color.
PSE=random(500,1200); // Select a random pause between the lights (to increase the surprise effect).
while (COLOR!=1 && digitalRead(Button)==HIGH)// This loop is repeated while color is Green or Blue AND button is held down.
{
digitalWrite(LEDGr, HIGH);
digitalWrite(LEDB, HIGH);
delay(PSE);
randomSeed(analogRead(0));
Beep=random(1,4); // Select whether to beep or not (1 in 3 times).
PSE=random(750,1200); // Select a random pause between the lights (to increase the surprise effect).
if (Beep==1)
{tone(13,1600,350);
delay(750);
noTone(13);}
if (COLOR == 2)
{digitalWrite(LEDGr, LOW);}
if (COLOR == 3)
{digitalWrite(LEDB, LOW);}
delay(PSE);
randomSeed(analogRead(0));
COLOR = random(1,4); // Select a random color.
}
if (COLOR == 1 && digitalRead(Button)==HIGH)// This loop is executed if the color is red.
{
digitalWrite(LEDGr, HIGH);
digitalWrite(LEDB, HIGH);
delay(PSE);
TME=millis(); // Time since this program has started (so Blue or Green loop included).
digitalWrite(LEDR, LOW);
while (digitalRead(Button)==HIGH)// This loop runs untill you have released the button, hence the reaction time.
{delay(1);}
lcd.display();
RTME=millis()-TME; // Time since Led is Red, hence reaction time.
lcd.print("Reaction Time:");
lcd.setCursor(0,1);
lcd.print(RTME);
}
if (COLOR != 1) // This step is executed if the color is NOT red but the Push button was released (wrong action).
{
lcd.print("Released too");
lcd.setCursor(0,1); // move to second line.
lcd.print("soon !!!");
tone(13,3000,1500);
delay(500);
noTone(13);
}
while (digitalRead(Button)==LOW) // The test does not re-start until the button is pushed once.
{delay(10);}
digitalWrite(LEDR, LOW); // Resets all lights to begin again.
digitalWrite(LEDB, LOW);
digitalWrite(LEDGr, LOW);
lcd.clear();
lcd.print("Hold Button to");
lcd.setCursor(0,1);
lcd.print("start.");
int Time=0;
delay(1000);
}
here are the errors
sketch_may19a.ino: In function 'void setup()':
sketch_may19a:21: error: a function-definition is not allowed here before '{' token
sketch_may19a:33: error: a function-definition is not allowed here before '{' token
sketch_may19a:124: error: expected `}' at end of input
sketch_may19a.ino: In function 'void setup()':
sketch_may19a:21: error: a function-definition is not allowed here before '{' token
sketch_may19a:33: error: a function-definition is not allowed here before '{' token
sketch_may19a:124: error: expected `}' at end of input
sketch_may19a.ino: In function 'void setup()':
sketch_may19a:21: error: a function-definition is not allowed here before '{' token
sketch_may19a:33: error: a function-definition is not allowed here before '{' token
sketch_may19a:124: error: expected `}' at end of input
sketch_may19a.ino: In function 'void setup()':
sketch_may19a:21: error: a function-definition is not allowed here before '{' token
sketch_may19a:33: error: a function-definition is not allowed here before '{' token
sketch_may19a:124: error: expected `}' at end of input
Hope I have got it right this time; Thanks for your help. Chaso.
Chaso, I am not sure what you mean by your last post. The code you posted compiles for me with no errors. Are you saying that you get the errors listed in your post ?
Hi UK Helibob, that is correct, all these errors show when I try to "verify" the code.
Seems like your copy and paste is going crazy. Start a fresh page, copy your code from this post and paste it in the IDE.
When I copy your code and paste it in the IDE, I get NO Errors!
Thankyou Codlink, it worked, verified and uploaded fine. Meanwhile I have solved the problem of where I was going wrong.
When starting a new code, the blank template looks like this below. I was pasteing my code where it says "put your setup code here , run once:"
I guess the extra Void setup() and { } s, upset the final result. In future I will clear the new template completely.Thanks everyone for your input. Chaso.
void setup()
{
// put your setup code here, to run once:
}
void loop()
{
// put your main code here, to run repeatedly:
}