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
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()
{
infraredReceiverDecode.begin();
}
void loop()
{
if(infraredReceiverDecode.available())
{
switch(infraredReceiverDecode.read())
{
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;
default: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 !!
cheers,
paul