Error message for fsm for line following robot using dijkstra algorithm any help would be appreciated thank you

I am making a robot ,and I am also fairly new to arduino,that finds the most optimal path in a maze this is the simple fsm that is just for testing the robot I have no idea whats wrong with the code.

i get this error meassage

Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino Uno"

pooy_motor_3:21:14: error: expected unqualified-id before ')' token

void forward(){

          ^

pooy_motor_3:28:11: error: expected unqualified-id before ')' token

void left(){

       ^

pooy_motor_3:35:12: error: expected unqualified-id before ')' token

void right(){

        ^

C:\Users\User\OneDrive\year 2\rob\pooy_motor_3\pooy_motor_3.ino: In function 'void setup()':

pooy_motor_3:42:6: error: redefinition of 'void setup()'

void setup() {

  ^~~~~

C:\Users\User\OneDrive\year 2\rob\pooy_motor_3\pooy_motor_3.ino:12:6: note: 'void setup()' previously defined here

void setup() {

  ^~~~~

C:\Users\User\OneDrive\year 2\rob\pooy_motor_3\pooy_motor_3.ino: In function 'void loop()':

pooy_motor_3:53:11: error: expected primary-expression before ')' token

forward();

       ^

pooy_motor_3:59:8: error: expected primary-expression before ')' token

left();

    ^

pooy_motor_3:65:9: error: expected primary-expression before ')' token

right();

     ^

pooy_motor_3:71:11: error: expected primary-expression before ')' token

reverse();

       ^

exit status 1

expected unqualified-id before ')' token
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

#define forward
int fO;
#define left
int lE;
#define right
int rI;
#define reverse
int rE;

//void reverse();
void setup() {
  // Pins 8 and 9 are used to set the direction, set one high and one low for one direction and swap them for the other direction.
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  // Pin 10 is used to set the power by using PWM on the enable pin
  pinMode(10, OUTPUT);
}

void forward(){
  digitalWrite(7, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
  digitalWrite(10, LOW);
}

void left(){
  digitalWrite(7, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, HIGH);
}

void right(){
  digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, LOW);
}

void setup() {
  pinMode(7, OUTPUT);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
 // one output pin for each of the motors 
 // 7 and 8 are the left and 9 10 are the right
  
}

void loop() {
  forward();
  digitalWrite(7, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(9, HIGH);
  digitalWrite(10, LOW);
  delay(1000);
  left();
    digitalWrite(7, HIGH);
  digitalWrite(8, LOW);
  digitalWrite(9, LOW);
  digitalWrite(10, HIGH);
  delay(1000);
  right();
    digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
  digitalWrite(10, LOW);
  delay(1000);
  reverse();
   digitalWrite(7, LOW);
  digitalWrite(8, HIGH);
  digitalWrite(9, LOW);
  digitalWrite(10, HIGH);
  delay(1000);

}

Get rid of this:

#define forward

and the other defines.

oh really? is that all
and thank you:)

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.