Let's Make Robots!

SUMBA - a sumo robot and my first project

pushes other bots out of the arena

Hi everybody, as some people allready know i am new to LMR and robots all together, meaning this is my first robot.

It was originally going to be a holiday project but when my science teacher gave us a holiday assignment that had rather open criteria, the bot for fun got given 4 weeks to be finished, so now with a bit over 2 weeks left I almost have the entire bot assembeled.

The chasses dimensions are 15cm wide X 15cm long X 5cm high

 

At the moment all i have is the unfinished chasse asembled (I still need to add holes for the wheels and skrew down the motor), and the code that i believe is finished, it may need some editing once i hook up the senors and test the whole thing out. 

here is a fritz of the wiring it will be more compact when actually put together, those are 1K resistors.

here 

also with the code im using PWM to control the motors because I have an NPN transistor between the motors and the batterys and i dont want to burn out the motors.

Here is the code:

(EDITED CODE) changed after seeing the comment by bdk6

CHANGE LOG: when one motor is running the other is set to off

 

 

#define RIGHTDC 5

#define LEFTDC 6

#define MIDDLEIR A0

#define LEFTIR A1

#define RIGHTIR A2

 

#define DANGER 1000

 

#define HALFSPEED 127

#define STOP 0

 

void setup() {

  pinMode(RIGHTDC, OUTPUT);

  pinMode(LEFTDC, OUTPUT);

}

 

void loop() {

  if (analogRead(MIDDLEIR) < DANGER) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else if (analogRead(RIGHTIR) < DANGER) {

    analogWrite (LEFTDC, HALFSPEED);

    analogWrite (RIGHTDC, STOP);

  } else if (analogRead(LEFTIR) < DANGER) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, STOP);

  } else if ((analogRead(LEFTIR) < DANGER) &&

             (analogRead(MIDDLEIR) < DANGER)) {

               analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

 

  } else if ((analogRead(RIGHTIR) < DANGER) && 

             (analogRead(MIDDLEIR) < DANGER)) {

               analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else if ((analogRead(LEFTIR) < DANGER) && 

             (analogRead(MIDDLEIR) < DANGER) && 

             (analogRead(RIGHTIR) < DANGER)) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else if ((analogRead(LEFTIR) < DANGER) && 

             (analogRead(RIGHTIR) < DANGER)) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else {

    analogWrite(LEFTDC, STOP);

    analogWrite(RIGHTDC, HALFSPEED);

  }

}

 

 

(OLD CODE)

#define RIGHTDC 5

#define LEFTDC 6

#define MIDDLEIR A0

#define LEFTIR A1

#define RIGHTIR A2

#define DANGER 1000

#define HALFSPEED 127

 

void setup() {

  pinMode(RIGHTDC, OUTPUT);

  pinMode(LEFTDC, OUTPUT);

}

 

void loop() {

  if (analogRead(MIDDLEIR) < DANGER) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else if (analogRead(RIGHTIR) < DANGER) {

    analogWrite (LEFTDC, HALFSPEED);

  } else if (analogRead(LEFTIR) < DANGER) {

    analogWrite(RIGHTDC, HALFSPEED);

  } else if ((analogRead(LEFTIR) < DANGER) &&

             (analogRead(MIDDLEIR) < DANGER)) {

               analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

 

  } else if ((analogRead(RIGHTIR) < DANGER) && 

             (analogRead(MIDDLEIR) < DANGER)) {

               analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else if ((analogRead(LEFTIR) < DANGER) && 

             (analogRead(MIDDLEIR) < DANGER) && 

             (analogRead(RIGHTIR) < DANGER)) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else if ((analogRead(LEFTIR) < DANGER) && 

             (analogRead(RIGHTIR) < DANGER)) {

    analogWrite(RIGHTDC, HALFSPEED);

    analogWrite(LEFTDC, HALFSPEED);

  } else {

    analogWrite(LEFTDC, 0);

  }

}

 

If you see anything that you think i could improve on please tell me, as i said i am a beginner and i would love any help that can be supplyed to me.

 

 

 

(MAJOR EDIT!!!)

i haven't updated this in a while so here is what has happened with my bot.

First off, the gear box that i was going to use had shafts that were  3 ml in diameter and they did not fit my wheels, so i looked for new wheels and coudnt find any to the right size so instead i got new motors, this leads to my next problem.

i looked for the motor on the website of the place that my sister works at and got her to buy them for me, i stuffed up and didnt look at the dimensions and i got motors that were much larger than i originally thought.

to combat this problen i got rid of three walls and the roof to make room for the new motors and battery pack.

i also edited the front of the bot so that the sensors had somewere to be placed seeing as they were originally going to be attatched to the roof.

finally, when i was about to finish the robot i found the the cable ties i had bought to hold the motors down weren't long enough.

 

by tommorow i should have the robot done and be ironing out the bugs so expect videos and pictures soon.

 there will also be updated code as i do not need to use PWM any more

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

As bdk6 suggested, but remember that this does not allow for the motors to go in reverse. For that, you should change from this type circuit to an H-bridge circuit.

                           (Click this drawing to view it bigger.)

thanks for the suggestion but for this robot I dont feel that I need it to reverse.

Welcome to LMR...

people generally try an ostacle avoider at first ,but you are after a sumo. I would definitely like to see it finished.

I suppose a sumo bot, in simple terms is the inverse?!

if it sees and object it goes for it, if not it looks for one!

that and an edge sensing function and you are onto a winner! (well, the project will work, you wont nessecarily win)

hmmmm !!!

I would have done an obstacle avoider but sumo bots are cooler and it is still basically an object avoidance bot, it just rams instead of dodges.