Hiparco

Recetas y trucos de GNU/Linux e informática en general

Alojado en http://guimi.net

BTControl

BTCONTROL


[SPANISH VERSION]

Download BTControl


INTRODUCTION


BTControl allows you to send pre-defined signals to a connected device via Bluetooth.
Its main use is to control robots made with Arduino and the like. And it’s open-source! Check the code!

It has two control modes, the Primo mode and Remote mode.

Primo is an Arduino-based game whose goal is to guide a small robot by creating instruction sequences using colourful instruction blocks.
The original game consists of two parts: the robot and the interface.
BTControl – Primo allows to replace the wood interface.

BTControl – Remote is designed to be used as a remote control similar to the radio-controlled vehicles.
Also includes 10 function buttons (A to J), and 5 Primo-like buttons.

Presentation:

Full Demo:

Go to index


BTControl – PRIMO


HOW DOES THE PRIMO INTERFACE WORK

In sequence, colored blocks indicating forward, turn left or right get are arranged.
Pressing the red button, the generated message is sent to the robot, which starts to follow the program.
There is also a block (round, green) that allows you to run the four blocks of the green rectangle (Routine).

MEANING OF BLOCKS

  • Red [straight arrow]: Forward
  • Yellow [spin]: Turn right
  • Blue [spin]: Turn Left
  • Green [Routine]: Executes the four blocks of the green rectangle
  • Gray [position]: Meaning no block (ignored)

Go to index


BTControl – REMOTE


HOW DOES THE REMOTE INTERFACE WORK

The remote has a control wheel on the right side to control a robot in a similar way to the radio-controlled vehicles.
While a direction is pressed, the robot continues to advance, until control is returned to the center, indicating the robot to stop.
It has 5 Primo-like buttons. These buttons cause the robot to perform discrete movements, with a set time for each.
It also includes 10 function buttons (A to J) that can allow, depending on the robot, to control lights, sound and any other function of the robot.

Go to index


CONECTING ROBOT


BTControl allows to control Bluetooth-paired robots.
The “Conections” option from the Settings, launches the Bluetooth settings of your device, allowing pair devices.
Paired devices appear in the BTControl menu, to select easily which one to use.

You can also check the “Auto-Connect” option, so the app will try to connect automatically with the last device connected.

If the app connects automatically with a device and you want to connect to another device, un-check the “Auto-Connect” option.

Go to index


TROUBLESHOOTING

The device I want to use is not listed on the menu

Use the Bluetooth settings to pair the device. If still does not appear try to restart the program.

The device does not connect properly

Errors occur when sending signals

Try:

  1. From the Bluetooth settings, delete the device (un-pair it)
  2. Reboot both devices
  3. Re-pair the device

Go to index


DEVELOPERS


The robot must have a working Bluetooth module (examples on my website).
BTControl sends out single-character signals that the robot must interpret.
Signals sent can be changed in the “Settings”, but if not modified are:

  • Primo* Signals:
    • Forward (Red): V
    • Left (Blue): W
    • Right (Yellow): Y
  • Primo-like Signals (from the remote):
    • Stop (Green): X
    • Backward (Red): Z
  • Control wheel Signals:
    • Numbers 1 to 9, being 1 front-left, front 2, …, stop 5, …, 9 back-right
  • Function buttons:
    • A to J buttons send the corresponding character

[*] At Primo mode, pressing the red button (run), BTControl composes the programmed message and adds ‘0’ at the end of the message.

You can reset default values, on the settings, press the menu button on your device and select “Reset default values”.

Arduino Template code


Download code

/*
 ***********************************
 *            BTCONTROL            *
 ***********************************
 * 2014 - Guimi (http://guimi.net) *
 ***********************************
 *
 * Este programa implementa un robot controlado por bluetooth utilizando los comandos pre-definidos del programa
 * BTControl para Android (BTControl - 2014 Guimi - http://guimi.net)
 *
 * El programa requiere de un modulo Bluetooth HC-05 para la comunicacion
 *
 * El ciclo principal escucha las instrucciones recibidas por Bluetooth y si las reconoce las ejecuta
 *
 * Para DEBUG se debe configurar el modulo serial a 9600 baudios con "Ambos NL & CR"
 *
 * 2014 - Guimi (http://guimi.net)
 *
 */

// DEBUG
//----------
#define DEBUG false // Indica si debemos realizar DEBUG mediante el puerto serie


// LIBRERIAS
//----------
#include <SoftwareSerial.h> //Librería que permite establecer comunicacion serie en pins diferentes al 0 y 1


// CONSTANTES
//-----------
#define BT_Rx 10 // Recepcion BT
#define BT_Tx 11 // Transmision BT
#define LED_ESTADO 13 // Pin del LED que marca el estado


// VARIABLES
//----------
int caracter; // Caracter recibido


// MODULOS
//--------
SoftwareSerial BT(BT_Tx,BT_Rx); // Inicializamos el BT, indicando los pines de Tx y Rx


// FUNCION SETUP
//--------------
void setup() {
  // Definimos cada pin como entrada o salida
  pinMode(LED_ESTADO,OUTPUT);

  // Indicamos que aun no hemos iniciado
  digitalWrite(LED_ESTADO, LOW);

  // Esperamos a que este encendido el modulo BT
  delay(500);
  // Preparamos la comunicacion mediante el modulo BT
  BT.begin(9600);
  delay(500);
  BT.flush();

  // Preparamos la comunicacion mediante el puerto serie y el modulo BT
  if (DEBUG) {
    Serial.begin(9600);
    
    // Notificamos que estamos listos
    Serial.write("Preparado:\n");
  }

  // Indicamos el inicio
  digitalWrite(LED_ESTADO, HIGH);

}


// FUNCION LOOP
//-------------
void loop() {

  // Si hay algo pendiente en el puerto Serial lo transmitimos
  // de forma transparente al modulo BT (que lo envia directamente al aparato vinculado)
  if (Serial.available()) {
    // Escribimos en el puerto BT lo que leemos en el puerto serie
    BT.write(Serial.read());
  }


  // Si hay algo pendiente en el puerto BT lo transmitimos
  // de forma transparente al puerto serie y buscamos comandos conocidos
  if (BT.available()) {
    // Buscamos comandos conocidos
    //---------------------------- 
    // Leemos el puerto
    caracter = BT.read();
    // Escribimos en el puerto serie lo que leemos en el puerto BT
    if (DEBUG) Serial.write(caracter);

    switch (caracter) {
      // CARACTER 0
      //------------------------------
      case '0':
        break;


      // RUEDA DE CONTROL (MOVIMIENTO)
      //------------------------------
      // Los ponemos los primeros porque necesitan la respuesta mas inmediata
      case '1':
        break;
      case '2':
        break;
      case '3':
        break;
      case '4':
        break;
      case '5':
        break;
      case '6':
        break;
      case '7':
        break;
      case '8':
        break;
      case '9':
        break;

        
      // BOTONES DE FUNCION (A-J)
      //------------------------------
      case 'A':
        break;
      case 'B':
        break;
      case 'C':
        break;
      case 'D':
        break;
      case 'E':
        break;
      case 'F':
        break;
      case 'G':
        break;
      case 'H':
        break;
      case 'I':
        break;
      case 'J':
        break;


      // BOTONES PRIMO Y SIMILARES
      //------------------------------
      case 'V':
        break;
      case 'W':
        break;
      case 'X':
        break;
      case 'Y':
        break;
      case 'Z':
        break;

    
      default: 
        break;

    }

  }
}

Download code

Go to index


ABOUT



BTControl by Güimi

Background image (light_wood_texture) by Petr Kratochvil.

Primo by Solid Labs

Go to index