Go Down

Topic: Arduino Robot (Read 128 times) previous topic - next topic

JBCoder

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);
      }
      }
 
 

vinceherman

A few things:
Use code tags when posting code.  If you do not know how, read the sticky post named How to use this forum - please read.
Auto-format your code.  CTRL-T in the editor.  This makes it easier to read and much easier to find mismatched curly brackets.

Describe the problem better.  It is usually best to follow this format.
I expected my sketch to do this.
Instead, my sketch does that.
This and That are different in this way...

slipstick

its now working can you help?
If it is now working then you don't have a problem. So perhaps you mean it's NOT working?

If you tell us in detail what it is actually doing and what you want it to do that is different we are more likely to be able to help.

Steve

Go Up