Hello, we're trying to make an arduino robot read white stop at a black line turn then pick up a bottle with an ultrasound sensor but its now working can you help? Here's our code
#include "MeMegaPi.h"
MeMegaPiDCMotor motor1(PORT1A);//Port 1 (-) = Forward
MeMegaPiDCMotor motor2(PORT1B);
MeMegaPiDCMotor motor3(PORT2A);// Port 2 (+) = Forward
MeMegaPiDCMotor motor4(PORT2B);
MeLineFollower lineFinder(PORT_6);
// MeUltrasonicSensor ultraSensor(PORT_7);//ultrasonic sensor
void setup()
{
Serial.begin(9600);
}
void loop()
{
//line following
int sensorState = lineFinder.readSensors();
switch(sensorState)
{
case S1_IN_S2_IN:// stop at black
break();
motor1.stop();
motor2.stop();
motor3.stop();
motor4.stop();
case S1_OUT_S2_IN:// turn on uneven
motor1.run(-73);
motor2.run(-73);
motor3.run(-73);
motor4.run(-73);
delay(2000);
break;
case S1_OUT_S2_OUT:// strait on white
motor1.run(-55);
motor2.run(-55);
motor3.run(55);
motor4.run(55);
break;
break;
motor1.run(55);
motor2.run(55);
motor3.run(55);
motor4.run(55);
}
}