Getting Started with Makeblock Arduino Programming
Gotchas about using Makeblock Orion
If you read my more detailed story on Makeblock earlier you will know why the Arduino boards made by Makeblock has some cool advantages worth exploring.
However as I’ve been dabbling in this it has become clear that there are at time a lot of loose ends and things that don’t work. For instance the plotter software mDraw
that Makeblock makes will crash when you give it anything beyond the most basic .SVG
file (macOS May 24 2019).
Makeblock has github page where you can download a lot of their software. So I tried downloading their Arduino software made specifically for my XY Plotter 2.0. While there is a lot of useful stuff there, it lacks polish. The demo software does not work at all. It is complex enough that debugging it for an Arduino novice is not fun.
So this is just advice, so you avoid making the same mistakes as me. My advice is to get their standard Makeblock library instead.
That in my experience makes it a lot easier to gradually build up and test stuff. It has plenty of example code, which allows you to test whatever hardware you have built one step at a time. Now as to why, do you actually need a special Makeblock Arduino library?
Why not just use the stuff that comes bundled with Arduino IDE upon installation. That is what I explain below.
How to use the Arduino IDE with Makeblock Orion board (Uno)
Regular Arduino programming involves reading and writing to particular pins on the Arduino. While if you work with Makeblock’s Arudino boards such as the Makeblock Orion, you are typically dealing with ports instead.
The Orion board has 8 different ports which you connect RJ25 plugs to. They look like the ones you use to connect stationary phones into the wall.
Each of these RJ25 cables you connect to the ports have 6 different wires. 2 of those wires are an Arduino input or output pin. Those pins are referred to as s1 (slot 1) and s2 (slot 2).
For instance if I have a limit switch connected to port 6 and slot 1 in code I write:
MeLimitSwitch limitSwitch1(PORT_6, SLOT1);
However you cannot write this kind of code out of the box when you install the Arduino IDE, because it does not come bundled with the Makeblock libraries.
So what you got to do is to go to Makeblock github repository, and download a .zip
file of this code repository. Fortunately this repo has exactly the kind of directory layout that the Arduino IDE expects from a third party library.
So you can just add this library to your IDE by going to:
Sketch > Include library > Add Zip library...
That is all! Now you are ready to try out Makeblock example programs which come with the library. Just go to:
File > Examples > MakeBlockDrive
Here is an example called SerialControlStepper, which demonstrates how easy it is to control your stepper motor from a serial connection. You just send numbers from 0 to 9 over the USB serial connection using the serial monitor accessible form the IDE. stepper.moveTo()
does an absolute movement, while stepper.move()
is relative.
include "MeOrion.h"
#include <SoftwareSerial.h>
MeStepper stepper(PORT_1);
void setup()
{
Serial.begin(9600);
// Change these to suit your stepper if you want
stepper.setMaxSpeed(1000);
stepper.setAcceleration(20000);
}
void loop()
{
if(Serial.available()) {
char a = Serial.read();
switch(a) {
case '0':
stepper.moveTo(0);
break;
case '1':
stepper.moveTo(200);
break;
case '2':
stepper.move(50);
break;
case '3':
stepper.move(100);
break;
case '4':
stepper.move(200);
break;
case '5':
stepper.move(400);
break;
case '6':
stepper.move(600);
break;
case '7':
stepper.move(4000);
break;
case '8':
stepper.move(8000);
break;
case '9':
stepper.move(3200);
break;
}
}
stepper.run();
}