I’ve found a few examples of how to make the IR version autonomous, but everything ive seen requires you to push a button on the included IR remote, which mine didnt come with obviously. My kid is looking at me like I failed him, and I don’t want to look like a moron in front of him haha
Starter Kit with BT - how do i make this thing autonomous?
Hi Leslie,
in order to make your robot autonomous, you need to write a little program (using either mBlock or the Arduino IDE) which you then upload to the bot using USB. Then you switch on the robot and (hopefully) it does what you intended it to do.
To use the Arduino IDE, you need to install the Makeblock Library, The library also provides a bunch of examples scripts for all modules, e.g. motor control and ultrasonic device, to name but a few.
I do always recommend the Arduino IDE as it does not distract you from the real thing (programming C), but if you never programmed in C language, mBlock may be easier to use, even without proper documentation. For both you will find a lot of helping people here when you come up with questions. But it is always a good idea to scan and search through the forum, as many questions have been asked before.
Have fun making robots!
Stefan
Thanks for the response!
I went ahead and download mBlock, the MakeBlock Library, and Arduino IDE. I mocked up a sketch in mBlock, pushed the button the said “Edit in Arduino IDE”, which opens up Arduino IDE with the code inside of it. However, whenever i try to compile the code, it comes up with this error:
collect2.exe: error: ld returned 1 exit status
Multiple libraries were found for “MeMCore.h”
Used: C:\Users\Dustin\Documents\Arduino\libraries\makeblock
Not used: C:\Program Files (x86)\mBlock\Arduino\libraries\makeblock
Error compiling.
I have the board type in mBlock to “mBot”, and the board type in Ardu9ino IDE as Leonardo.
Here is the code i’m trying to compile
#include <Arduino.h>
#include <Wire.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include <MeMCore.h>
double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
MeUltrasonicSensor ultrasonic_4(4);
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
void setup(){
while(!((ultrasonic_4.distanceCm()) < (5 )))
{
motor_9.run((9)==M1?-(100):(100));
motor_10.run((10)==M1?-(100):(100));
}
motor_9.run((9)==M1?-(0):(0));
motor_10.run((10)==M1?-(0):(0));
}
void loop(){
}
Hi,
Could you please edit your post above and enclose your code example in “preformatted” markup? It is the </> icon in the editor. Makes it more readable.
Your code looks very odd to me. Seems to be auto generated by mBlock. I will come back to you after you editex your post and your code is edited as preformatted text.
Stefan
Yes, I am using mBlock and then trying to use Arduino IDE to compile. I was able to get the robot to do exactly what I want while tethered inside mBlock, but it doesn’t work when its not tethered via USB. I’m assuming its because I need to compile and upload the code. Here is the new code I’ve been using, which also still gives the same error message whenever I try to compile it inside Arduino IDE - hopefully this formats properly.
`#include <Arduino.h>
#include <Wire.h>
#include <Servo.h>
#include <SoftwareSerial.h>
#include <MeOrion.h>
double angle_rad = PI/180.0;
double angle_deg = 180.0/PI;
MeUltrasonicSensor ultrasonic_4(4);
MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
void setup(){
}
void loop(){
if((ultrasonic_4.distanceCm()) < (20)){
motor_9.run(100);
motor_10.run(-100);
}else{
motor_9.run(-155);
motor_10.run(-155);
}
}
`
Well I feel pretty dumb. I just realized I can upload the code from within mBlock. Please disregard, but thank you for the help
OK, you gave the explanation yourself:
It is not possible to directly transfer mBlock code to Arduino IDE and expect it to work all the same. For your information, I post the Makeblock example code for the Arduino IDE here…
#include "MeOrion.h"
//these motors are connected through regular ports
MeDCMotor motor1(PORT_1);
MeDCMotor motor2(PORT_2);
//these motors are connected through the motor controller
MeDCMotor motor3(M1);
MeDCMotor motor4(M2);
//we use a variable to set the speed, just for the fun of it...
uint8_t motorSpeed = 100;
void setup()
{
nothing to set up here
}
void loop() //repeated until power off
{
motor1.run(motorSpeed); /* value: between -255 and 255. */
motor2.run(motorSpeed); /* value: between -255 and 255. */
motor3.run(motorSpeed);
motor4.run(motorSpeed);
delay(2000);
motor1.stop();
motor2.stop();
motor3.stop();
motor4.stop();
delay(100);
motor1.run(-motorSpeed);
motor2.run(-motorSpeed);
motor3.run(-motorSpeed);
motor4.run(-motorSpeed);
delay(2000);
motor1.stop();
motor2.stop();
motor3.stop();
motor4.stop();
delay(2000);
}
Cheers, Stefan