So I am using arduino software 1.8.4 and I have the adafruit v1 motorshield + adafruit motorshield v1 library and when I try to upload my code I get this error
'run' was not declared in this scope
How can I fix this?
Here is my code:
#include <AFMotor.h>
AF_DCMotor bal(1, MOTOR12_8KHZ);
AF_DCMotor jobb(2,MOTOR12_8KHZ);
#define trig 2
#define echo 4
int dur;
long dis;
void setup() {
// put your setup code here, to run once:
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
Serial.begin(9600);
}
void loop() {
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
dur = pulseIn(echo, HIGH);
dis = dur*0.034/2;
Serial.print("Távolság cm: ");
Serial.print(dis);
delay(1000);
if (dis > 20)
{
run.jobb(FORWARD);
run.bal(FORWARD);
}
else if (dis <20)
run.bal(BACKWARD); //Here are the errors
run.jobb(BACKWARD);
}