How to Use Scratch or Arduino to Program a MBot

by Makeblock Robotics in Circuits > Robots

12477 Views, 42 Favorites, 0 Comments

How to Use Scratch or Arduino to Program a MBot

QQ截图20161109094518.jpg

A few days ago, I made a robot by Makeblock. We call it mBot---a robot better fit education and home use. It is simple to use, and more affordable. We believe this is the best robotic product in its category.

The mBot is designed especially for mBlock to help teachers and kids to have hands-on experience about robot and explore STEM education.Now I will show you how to build it by steps.

For more information about makeblock, please visit mBlock website listed below:

www.makeblock.com

Introduction of Mblock

1-1.jpg
1-2.jpg

The mBlock is a customized version of Scratch which is a graphic programming language(developed by the lifelong kindergarten group at MIT Media Lab). With mBlock, those who are familiar with Scratch can easily interact with electronic modules in Arduino eco-system. Its electronic modules is based on Arduino open source platform, and mechanical parts are compatible with Makeblock parts and lego parts, so it is easy for you to extend.

For more information about mBlock, please visit mBlock website listed below:
BUY NOW

Tools You Need

2.jpg

Mechanical Part List

1*Metal Base Plate

2*TT Gear Motor

2*Wheel

2*Tyre

1*Plastic Universal Wheel

1*Magic Tape 20*30mm

6*Brass Stud M4*25

14*Socket Cap Screw M4*8

6*Nut M4

4*Nut M3

4*Philip's Head Screw M3*25

2*Tapping Screw M2.2*9.5

buy now

Electronic Modules List:

1*Arduino Based Control Board

1*Me Ultrasonic Sensor V3.0

1*Me Line Follower V2.2

1*Me Infrared Controller

1*Bluetooth

1*Battery Holder for (4)AA

4*RJ25 Cable

1*USB A-Male to B-Male Cable

buy now

Build the Mechanical Part

3-1.jpg
3-2.jpg

The construction of mechanical part mainly is building the motors and wheels, and the motors are TT Gear Motor, which are usual in our lives. To assembling them together is very convenient, because you just need to tighten several screws. The pictures above will show you some details in assembling processes.

For more information about makeblock, please visit mBlock website listed below:

www.makeblock.com

Build the Electronic Part

4-1.jpg
4-2.jpg
4-3.jpg
4-4.jpg

The construction of the electronic part mainly is building the electronic modules together and wiring. The electronic modules that you will use include the Line Follower module, the Ultrasonic Sensor module, the Bluetooth module and the Arduino Based Control Board. (The Bluetooth module and the Arduino Base Control Board are fixed together already.) I will show you the details in assembling process as pictures above.

Use the Scratch (mBlock) to Programming

QQ截图20161109095616.jpg

The mBlock is a customized version of scratch. It is easy to use mBlock to interact with electronic modules.

For more information about mBlock, please visit mBlock website listed below:

www.mblock.cc

Use the Arduino IDE to Programming

QQ截图20161109095754.jpg

Arduino is an

open-source electronics platform based on easy-to-use hardware and software. It’s intended for anyone making interactive projects. The Arduino development environment makes it easy to write code and upload it to the I/O board. You can use Arduino language (C\C++) to interace with Arduino hardware. We provide a complete Arduino using environment.

Following is one simple code for controlling the mBot by Infrared Controller.

#include

#include

#include

#include "mBot.h"

#include "MePort.h"

MeBoard myBoard(mBot);

#include "MeIR.h"

#include "MeDCMotor.h"

double angle_rad = PI/180.0;

double angle_deg = 180.0/PI;

MeIR ir;

MeDCMotor motor_9((MEPORT)9);

MeDCMotor motor_10((MEPORT)10);

void setup(){

ir.begin();

}

void loop(){

if(ir.keyPressed(64)){

motor_9.run(255);

motor_10.run(255);

}else{

if(ir.keyPressed(25)){

motor_9.run(-255);

motor_10.run(-255);

}else{

if(ir.keyPressed(7)){

motor_9.run(255);

motor_10.run(-255);

}else{

if(ir.keyPressed(25)){

motor_9.run(-255);

motor_10.run(255);

}else{

motor_9.run(0);

motor_10.run(0);

}

}

}

}

ir.loop();

}

For more information about Arduino, please visit website listed below:

learn.makeblock.cc/learning-arduino

Playing With It!

mBOT
mBot_control_by_smartphone
the air balloon game

We can use the mBot built by ourselves to play some games or make them complete some functions autonomously, such as playing football, ultrasonic obstacle-avoiding and following line. The videos above will show you some ways to play with it.

For more information about makeblock, please visit mBlock website listed below:
www.makeblock.com