Expected’,‘or’,‘before long’ error

Hello Community
I have a bug in my Code but i can´t find a solution for the problem.
I search few hours but nothing helps maybe i´m blind.

Copy & paste the code in the forum. That picture is not readable.

So a few hours of fault finding takes all Your power…
I worked an entire year to find a really tricky fault…

1 Like

Post the code in code tags.

Post the entire error message. Paraphrasing the error message leaves out important information.

For the first error, I’d agree, you’re going blind.

It looks like on line 15 the “l” in long has a modifier above it. I would delete that line and retype.

Normaly not but that is a really easy bug. The solution should be solved in few minutes not in hours.

Hi, @elkaz
Welcome to the forum.

Please read the post at the start of any forum , entitled “How to use this Forum”.

To add code please click this link;

  • What model Arduino are you using?
  • Can you please post a copy of your circuit?
  • What is your code supposed to do?
  • Can you please tell us your electronics, programming, arduino, hardware experience?

Thanks… Tom… :grinning: :+1: :coffee: :australia:

Here is the code .

#include <Arduino.h>
#include <AccelStepper.h>
#include <wire.h>
#include <LiquidCrystal.h>

#define endschalter 9 // Endschalter pin festlegen
#define relais_1 16 // Relais pin festlegen
#define relais_2 13
#define relais_3 14
#define relais_4 15

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

AccelStepper stepper(1,2,3); // pin konfigurieren für ena dir pul

long position = 0;
int endlage;
long startpunkt = 0;
long pos_1, pos_2, pos_3, pos_4;
int zaehler = 0;

void setup()
{
  lcd.begin(16,2);
  Serial.begin(9600);
  pinMode(endschalter, INPUT_PULLUP);
  pinMode(relais_1, OUTPUT);
  pinMode(relais_2, OUTPUT);
  pinMode(relais_3, OUTPUT);
  pinMode(relais_4, OUTPUT);
  delay(5);
  
  // Starpunkt anfahren
  stepper.setMaxSpeed(100.0);
  stepper.setAcceleration(100.0);
  Serial.println("Endschalter anfahren");
  lcd.setCursor(0,0);
  lcd.print("Endsch. anfahren");

  while(!digitalRead(endschalter))
  {
    stepper.moveTo(startpunkt);
    stepper.run();
    startpunkt++;
    delay(5);
  }
  stepper.setCurrentPosition(0);
  Serial.println("Startpunkt angefahren");
  lcd.print("Endsch. angefahren");

}

void loop()
{
  stepper.moveTo(pos_1);
  digitalWrite(relais_1, HIGH);
  delay(5);
  digitalWrite(relais_1, LOW);

  stepper.moveTo(pos_2);
  digitalWrite(relais_2, HIGH);
  delay(5);
  digitalWrite(relais_2, LOW);

  stepper.moveTo(pos_3);
  digitalWrite(relais_3, HIGH);
  delay(5);
  digitalWrite(relais_3, LOW);

  stepper.moveTo(pos_4);
  digitalWrite(relais_4, HIGH);
  delay(5);
  digitalWrite(relais_4, LOW);

  while(!digitalRead(endschalter))
  {
    stepper.moveTo(startpunkt);
    stepper.run();
    startpunkt++;
    delay(5);
  }
  zaehler++;
  Serial.println("Stueckzahl :");
  Serial.println(zaehler);



}

My machine needs Wire.h, not wire.h. Apart from that it’s a clean compile.

1 Like

I use an Arduino Uno with VS Code an platform IO.
I wrote for 2-3 years code for a project. The code works and i was happy but i forgot so much i begin nearly null.
Sorry i didnt draw a plan.
The code should controll a Steppermotor with 4 Relais and get an input from Switch for zerro point.
I use a LCD Keypad for control the positions. The Stepper is controled by TB6600 Steperdriver.
The functionality is in the setup code drive to the beginning point. In the loop section drive to point1 open relais1 close relais1
then drive to point2 open relais2 close relais2
then repeat until point4.
After relais4 are closed drive until zero point switch are on.
Then count +1 and repeat.
I hope this helps

Unbelievable but it´s true it´s helps but why ?
It was not empty. After i delete it jumps down to int

then i make this

long position = 0;int endlage;long startpunkt = 0;long pos_1, pos_2, pos_3, pos_4;int zaehler = 0;

then i delete the empty row becouse the red overline was also in the empty row and now it works.

I think it was an scary bug in the Editor. And thank you for the tip with WIre.h

1 Like

I’ve run into this before. Usually when I copy code from some other source. Extended characters sneak into the code. I’ve also found if a line causes an error its a good idea to delete and retype (not copy and paste).

Hi,
I have found if I copy a program off the net.
Then paste into Notbook++, select C++ language.
When I then “select ALL” and copy and paste that into the IDE, most of the hidden bugs have been removed.

Tom… :smiley: :+1: :coffee: :australia:

1 Like

I use sublime text. I’ll bet both Notepad++ and sublime have some command or addin to clear extended characters.