More crazyness with braces!

The in last statement TempA, which is designated as int, causes a name type error. I have tried every combination of braces I can think of and no luck.

void loop() {

Track5BY = digitalRead(Track5);
if (Track5BY == HIGH)
{
Serial.println("No Obstacle");
digitalWrite(BLED, LOW);
}
else
{
Serial.println("Obstacle");
digitalWrite(BLED, HIGH);

delay(1500); }}

TempA = digitalRead(Asens);

Please post ALL your code, using code tags.

I am new to his. What are code tags?

Post all the code using copy/paste, select it, and use the "</>" editor button.

There are also extensive instructions on how to use this forum, at the top of every forum topic.

Note that this line is outside of the loop function.

TempA = digitalRead(Asens);

Read the forum guidelines to see how to properly post code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags. The autoformat will often show where there are missing or mismatched brackets.

If you are getting error messages please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

Ok, I will study that but in the mean time the code I pasted IS all the code I am working with because I just started to write the program.

Does your program have a setup function?

That is not a complete Arduino program, as it is missing setup() and variable defs.

Minimal, complete Arduino program (in code tags).

void setup() {
  // put your setup code here, to run once:
}

void loop() {
  // put your main code here, to run repeatedly:
}

If you run autoformat on the snippet that you posted, you can see what @jremington is saying about outside of loop.

void loop()
{

   Track5BY = digitalRead(Track5);
   if (Track5BY == HIGH)
   {
      Serial.println("No Obstacle");
      digitalWrite(BLED, LOW);
   }
   else
   {
      Serial.println("Obstacle");
      digitalWrite(BLED, HIGH);

      delay(1500);
   }
} // closes loop

TempA = digitalRead(Asens);

Yes: void setup() {
pinMode(RLED, OUTPUT);
pinMode(BLED, OUTPUT);
pinMode(YLED, OUTPUT);
pinMode(Asens, INPUT);
pinMode(Bsens, INPUT);
pinMode(Csens, INPUT);
pinMode(SW82R, OUTPUT);
pinMode(SW82N, OUTPUT);
Serial.begin(9600);

See reply #2

Ok-here is the whole kit & kabootle
int RLED = 4; // RLED pin
int BLED = 3; // BLED pin
int YLED = 2; // YLED pin
int SW82R = 6;
int SW82N = 7;
int Asens = 9;
int Bsens = 10;
int Csens = 11;
int Track5 = 5;
int TempA = (HIGH);
int TempB = (HIGH);
int TempC = (HIGH);
int Track5BY = (HIGH);

void setup() {
pinMode(RLED, OUTPUT);
pinMode(BLED, OUTPUT);
pinMode(YLED, OUTPUT);
pinMode(Asens, INPUT);
pinMode(Bsens, INPUT);
pinMode(Csens, INPUT);
pinMode(SW82R, OUTPUT);
pinMode(SW82N, OUTPUT);
Serial.begin(9600);
}
void loop() {

Track5BY = digitalRead(Track5);
if (Track5BY == HIGH)
{
Serial.println("No Obstacle");
digitalWrite(BLED, LOW);
}
else
{
Serial.println("Obstacle");
digitalWrite(BLED, HIGH);

delay(1500);

}
}

TempA = digitalRead(Asens);

That snippet is incomplete. No closing bracket.

Always post the whole code, in code tags and formatted, please.

Please edit post #13 to add code tags.

Sorry it is there I just failed to copy it.

Really, so you pretty much ignore everything that was requested and suggested.

Chill out- I don't have any idea what "code tags" are and and I find the amount of arrogance on this forum beyond belief but having spent 40 years as a computer technician, I have come to expect that from the software community.

And here I was expecting to see the usual "Give me a break, I'm only 11 years old!".

Good luck with your project.

int RLED = 4; // RLED pin
int BLED = 3; // BLED pin
int YLED = 2; // YLED pin
int SW82R = 6;
int SW82N = 7;
int Asens = 9;
int Bsens = 10;
int Csens = 11;
int Track5 = 5;
int TempA = (HIGH);
int TempB = (HIGH);
int TempC = (HIGH);
int Track5BY = (HIGH);

void setup()
{
   pinMode(RLED, OUTPUT);
   pinMode(BLED, OUTPUT);
   pinMode(YLED, OUTPUT);
   pinMode(Asens, INPUT);
   pinMode(Bsens, INPUT);
   pinMode(Csens, INPUT);
   pinMode(SW82R, OUTPUT);
   pinMode(SW82N, OUTPUT);
   Serial.begin(9600);
}
void loop()
{

   Track5BY = digitalRead(Track5);
   if (Track5BY == HIGH)
   {
      Serial.println("No Obstacle");
      digitalWrite(BLED, LOW);
   }
   else
   {
      Serial.println("Obstacle");
      digitalWrite(BLED, HIGH);

      delay(1500);

   }
}  // Move this to below the TempA line and the code will compile

TempA = digitalRead(Asens);

There is your code posted in code tags and formatted. You see the TempA line is still outside of any function cause the loop is closed before that line.

So asking you to follow the rules is arrogance? We ask that code is posted in code tags because the forum software will mess certain things up and make code unreadable. We ask the the code be formatted to make if easy to read and follow (and therefore easier to debug). If that is to much for you I suggest that you try a different forum.

2 Likes

No. I just felt your reply was arrogant but I do thank you for your help. Now I know what code tags are and I also thank you for correcting the code.