loading

Arduino not programed?

Mr. Randofo,

I copied from your program and when I tried to up load, it said, exit status 1

'stopDriving' was not declared in this scope. Please see below to see what I actually wrote. Can you please help?

Thank you,

Hugo

#include <Servo.h>

Servo ContinuousServo1;

Servo ContinuousServo2;

void setup() {

// put your setup code here, to run once:

ContinuousServo1.attach(6);

ContinuousServo2.attach(7);

ContinuousServo1.write(94);

ContinuousServo2.write(94);

}

void loop() {

// put your main code here, to run repeatedly:

int range=random(4);

switch(range){

case0:

right();

delay(500);

stopDriving();

delay(1000);

break;

case1:

left();

delay(500);

stopDriving();

delay(1000);

break;

case2:

forward();

delay(500);

stopDriving();

delay(1000);

break;

case3:

backward();

delay(500);

stopDriving();

delay(1000);

break;

}

delay(1);

}

//Function to stop driving

void stopDiving(){

ContinuousServo1.write(94);

ContinuousServo2.write(94);

}

//Function to drive forward

void forward(){

ContinuousServo1.write(84);

ContinuousServo2.write(104);

}

//Function to drive backward

void backward(){

ContinuousServo1.write(104);

ContinuousServo2.write(84);

}

//Function to drive right

void right(){

ContinuousServo1.write(104);

ContinuousServo2.write(104);

}

//Function to drive left

void left(){

ContinuousServo1.write(84);

ContinuousServo2.write(84);

}


randofo1 month ago

Somehow you changed the name of the stopDriving function to stopDiving. You need to correct that spelling unless you are intending for your robot to join the Olympic high dive team. The Arduino program is very literal.