Hi all, doing a school project, making an Arduino based fire fighting robot. I am using the following code:
#include <Servo.h>
Servo myservo;
int pos = 0;
boolean fire = false;
#define Forward_S 8 //forward sensor
#define LM1 2 // left motor
#define LM2 3 // left motor
#define RM1 4 // right motor
#define RM2 5 // right motor
#define pump 6
void setup()
{
pinMode(Forward_S, INPUT);
pinMode(LM1, OUTPUT);
pinMode(LM2, OUTPUT);
pinMode(RM1, OUTPUT);
pinMode(RM2, OUTPUT);
pinMode(pump, OUTPUT);
}
void put_off_fire()
{
delay (500);
digitalWrite(LM1, HIGH);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, HIGH);
digitalWrite(pump, HIGH);
delay(500);
}
digitalWrite(pump,LOW);
fire=false;
}
void loop()
{
//Do not move the robot
digitalWrite(LM1, HIGH);
digitalWrite(LM2, HIGH);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, HIGH);
}
else if (digitalRead(Forward_S) ==0) //If Fire is straight ahead
{
//Move the robot forward
digitalWrite(LM1, HIGH);
digitalWrite(LM2, LOW);
digitalWrite(RM1, HIGH);
digitalWrite(RM2, LOW);
fire = true;
}
delay(300); //Slow down the speed of robot
while (fire == true)
{
put_off_fire();
}
}
The code shows the following error(s):
arduino_based_fire_fighting_robot:36:15: error: expected constructor, destructor, or type conversion before '(' token
digitalWrite(pump,LOW);
^
arduino_based_fire_fighting_robot:37:3: error: 'fire' does not name a type
fire=false;
^~~~
arduino_based_fire_fighting_robot:38:1: error: expected declaration before '}' token
}
^
exit status 1
expected constructor, destructor, or type conversion before '(' token
Newbie to Arduino, found the code off a tutorial. Any help would be greatly appreciated. Cheers