MAKESENSE TOOLS

MakeSense Blue

Control your OrbitCore projects from your phone or computer over Bluetooth: a game pad, your own buttons, sliders and a terminal. Works with the HC-05, HC-06 and HM-10 modules.

1 · Connect

○ not connected

Pair the module in your phone or computer Bluetooth settings first (PIN 1234 or 0000).

2 · Profile

Hold a direction to drive, let go to stop. On a computer: arrow keys or W A S D, space = stop.

Messages

Sent messages and the OrbitCore's replies appear here.

Help

What works where
Classic (HC-05/06)Low Energy (HM-10)
Chrome / Edge on a computeryesyes
Chrome on Android (version 137+)yesyes
iPhone / iPadnoin the Bluefy browser
Firefox, Safarinono
Connect a module, step by step
  1. Wire the module to your OrbitCore: VCC to 5V, GND to GND, TXD to pin 2 and RXD to pin 3. Flash a program that listens on pins 2 and 3 at 9600 baud (the example code below).
  2. HC-05 or HC-06: pair it once in your phone's or computer's Bluetooth settings (PIN 1234 or 0000). Then choose Classic Bluetooth here and press Connect.
  3. HM-10 and other Low Energy modules: do not pair them in the settings. Choose Bluetooth Low Energy and pick the module from the list.
  4. The module's LED stops blinking fast when it is connected.
Example board code for “MakeSense Robot Car”

For OrbitCore, with the module on pins 2 and 3. Copy it into OrbitCoder and flash it.

// MakeSense Robot Car (Fundamentals of Robotics diploma, lessons 5.3 to 6.4)
// From MakeSense Blue: F B L R = drive, S = stop, 0-9 = speed, A = auto (avoid obstacles), M = manual, D = distance
#include <SoftwareSerial.h>
SoftwareSerial BT(2, 3);            // HC-05 TXD -> pin 2, RXD -> pin 3

const int ENA = 5, IN1 = 7, IN2 = 8;
const int ENB = 6, IN3 = 9, IN4 = 10;
const int TRIG = 11, ECHO = 12;     // HC-SR04
int speed = 200;
bool autoMode = false;
char last = 'S';

void setup() {
  pinMode(ENA, OUTPUT); pinMode(ENB, OUTPUT);
  pinMode(IN1, OUTPUT); pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT); pinMode(IN4, OUTPUT);
  pinMode(TRIG, OUTPUT); pinMode(ECHO, INPUT);
  BT.begin(9600);
  BT.println("ready");
}

void loop() {
  if (BT.available()) {
    char c = BT.read();
    if (c >= '0' && c <= '9') speed = map(c - '0', 0, 9, 100, 255);
    else if (c == 'A') { autoMode = true; BT.println("auto"); }
    else if (c == 'M') { autoMode = false; stopMotors(); BT.println("manual"); }
    else if (c == 'D') { BT.print(readCm()); BT.println(" cm"); }
    else if (!autoMode) drive(c);
  }
  if (autoMode) avoid();
  else if (last == 'F') {                // safety brake when driving forward
    long cm = readCm();
    if (cm > 0 && cm < 15) { stopMotors(); last = 'S'; BT.println("too close"); }
  }
}

void drive(char c) {
  if (c == 'F') forward(speed);
  if (c == 'B') backward(speed);
  if (c == 'L') turnLeft(speed);
  if (c == 'R') turnRight(speed);
  if (c == 'S') stopMotors();
  last = c;
}

void avoid() {
  long cm = readCm();
  if (cm > 0 && cm < 25) {
    stopMotors();    delay(200);
    backward(180);   delay(300);
    turnRight(200);  delay(400);
  } else {
    forward(180);
  }
  delay(50);
}

long readCm() {
  digitalWrite(TRIG, LOW);  delayMicroseconds(2);
  digitalWrite(TRIG, HIGH); delayMicroseconds(10);
  digitalWrite(TRIG, LOW);
  long t = pulseIn(ECHO, HIGH, 30000);
  return t * 0.034 / 2;
}

void motors(int a1, int a2, int b1, int b2, int sp) {
  digitalWrite(IN1, a1); digitalWrite(IN2, a2);
  digitalWrite(IN3, b1); digitalWrite(IN4, b2);
  analogWrite(ENA, sp); analogWrite(ENB, sp);
}
void forward(int sp)   { motors(HIGH, LOW, HIGH, LOW, sp); }
void backward(int sp)  { motors(LOW, HIGH, LOW, HIGH, sp); }
void turnLeft(int sp)  { motors(LOW, HIGH, HIGH, LOW, sp); }
void turnRight(int sp) { motors(HIGH, LOW, LOW, HIGH, sp); }
void stopMotors()      { motors(LOW, LOW, LOW, LOW, 0); }