Bumper car with limit switch


Hello makeblock and fans,

I have been unable to play with makeblock for several months, but hopefully I am back now. I had some time yesterday and basically had to re-discover everything again :blush:

Below a very simple car that uses a bumper controlled by two limit switches.

Here is the code (it is very simple, almost copy/paste from the demo files):

#include <Makeblock.h>
#include <Arduino.h>
#include <SoftwareSerial.h>
#include <Wire.h>

MeDCMotor motor1(M1);
MeDCMotor motor2(M2);
MeInfraredReceiver infraredReceiverDecode(PORT_4); 
MeLimitSwitch limitSwitch1(PORT_6); 
MeLimitSwitch limitSwitch2(PORT_7); 

uint8_t motorSpeed = 255;

void setup()

void loop()
            case IR_BUTTON_PLUS: motor1.run(-motorSpeed) ; motor2.run(-motorSpeed); break;
            case IR_BUTTON_MINUS: motor1.run(motorSpeed) ; motor2.run(motorSpeed); break;
            case IR_BUTTON_PLAY: motor1.stop() ; motor2.stop() ; break;
    if(!limitSwitch1.touched()){ motor1.run(motorSpeed) ; motor2.run(motorSpeed); delay(1000);}
    if(!limitSwitch2.touched()){ motor1.run(motorSpeed) ; motor2.run(motorSpeed); delay(1000);}

A detail of the bumper (I only used makeblock parts):

I hope to find some time soon to do more interesting stuff!

Ah by the way, the Infrared works really good now !!



The idea was to build a car that would automatically back away when hitting a wall.



Clever design, paulcobbaut:). Limitswitch + tyre are very smart. Maybe we can use it on our football robot.

BTW, we have hold twice Hackmarathon recently and we got lots of interesting projects. I think you would like them.


There is a guy who made a bumper which is very similar with yours. You may like it. http://forum.makeblock.cc/t/new-product-testing-mechanical-parts/449


Thank You Paulcobbaut.