{"id":1733,"date":"2014-07-30T12:01:11","date_gmt":"2014-07-30T10:01:11","guid":{"rendered":"http:\/\/guimi.net\/blogs\/hiparco\/?page_id=1733"},"modified":"2014-07-31T09:56:20","modified_gmt":"2014-07-31T07:56:20","slug":"btcontrol","status":"publish","type":"page","link":"http:\/\/guimi.net\/blogs\/hiparco\/btcontrol\/","title":{"rendered":"BTControl"},"content":{"rendered":"<p><a name=\"menu\"><\/p>\n<h1>BTCONTROL<\/h1>\n<p><\/a><br \/>\n[<a href=\"http:\/\/guimi.net\/blogs\/hiparco\/btcontrol-es\/\">SPANISH VERSION<\/a>]<\/p>\n<table border=\"0\">\n<tr>\n<td><img decoding=\"async\" src=\"\/imgs\/blog\/hiparco\/btcontrol\/logo.png\"><\/td>\n<td>\n<ul>\n<li><a href=\"#intro\">INTRODUCTION<\/a>\n<li><a href=\"#primo\">BTControl &#8211; PRIMO<\/a>\n<li><a href=\"#mando\">BTControl &#8211; REMOTE<\/a>\n<li><a href=\"#conexion\">CONECTING ROBOT<\/a>\n<li><a href=\"#problemas\">TROUBLESHOOTING<\/a>\n<li><a href=\"#desarrolladores\">DEVELOPERS<\/a>\n<ul>\n<li><a href=\"#template\">ARDUINO TEMPLATE CODE<\/a><\/ul>\n<li><a href=\"#creditos\">ABOUT<\/a>\n<\/ul>\n<\/td>\n<\/tr>\n<\/table>\n<p>Download <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=net.guimi.btcontrol\">BTControl<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"intro\"><\/p>\n<h2>INTRODUCTION<\/h2>\n<p><\/a><br \/>\n<b>BTControl<\/b> allows you to send pre-defined signals to a connected device via Bluetooth.<br \/>\nIts main use is to control robots made with Arduino and the like. And it&#8217;s open-source! <a href=\"https:\/\/github.com\/Guimi0\/btcontrol\">Check the code!<\/a><\/p>\n<p>It has two control modes, the Primo mode and Remote mode.<\/p>\n<p><a href=\"http:\/\/www.primo.io\">Primo<\/a> is an Arduino-based game whose goal is to guide a small robot by creating instruction sequences using colourful instruction blocks.<br \/>\nThe original game consists of two parts: the robot and the interface.<br \/>\n<b>BTControl &#8211; Primo<\/b> allows to replace the wood interface. <\/p>\n<p><b>BTControl &#8211; Remote<\/b> is designed to be used as a remote control similar to the radio-controlled vehicles.<br \/>\nAlso includes 10 function buttons (A to J), and 5 Primo-like buttons. <\/p>\n<p>Presentation:<br \/>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/I3HQQKwanYA\" frameborder=\"0\" allowfullscreen><\/iframe><br \/>\nFull Demo:<br \/>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"\/\/www.youtube.com\/embed\/VZykmznC_hA\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"primo\"><\/p>\n<h2>BTControl &#8211; PRIMO<\/h2>\n<p><\/a><br \/>\n<img decoding=\"async\" src=\"\/imgs\/blog\/hiparco\/btcontrol\/Primo.png\"><\/p>\n<h3>HOW DOES THE PRIMO INTERFACE WORK<\/h3>\n<p>In sequence, colored blocks indicating forward, turn left or right get are arranged.<br \/>\nPressing the red button, the generated message is sent to the robot, which starts to follow the program.<br \/>\nThere is also a block (round, green) that allows you to run the four blocks of the green rectangle (Routine).<\/p>\n<h3>MEANING OF BLOCKS<\/h3>\n<ul>\n<li>Red [straight arrow]: Forward\n<li>Yellow [spin]: Turn right\n<li>Blue [spin]: Turn Left\n<li>Green [Routine]: Executes the four blocks of the green rectangle\n<li>Gray [position]: Meaning no block (ignored)<\/ul>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"mando\"><\/p>\n<h2>BTControl &#8211; REMOTE<\/h2>\n<p><\/a><br \/>\n<img decoding=\"async\" src=\"\/imgs\/blog\/hiparco\/btcontrol\/Mando.png\"><\/p>\n<h3>HOW DOES THE REMOTE INTERFACE WORK<\/h3>\n<p>The remote has a control wheel on the right side to control a robot in a similar way to the radio-controlled vehicles.<br \/>\nWhile a direction is pressed, the robot continues to advance, until control is returned to the center, indicating the robot to stop.<br \/>\nIt has 5 Primo-like buttons. These buttons cause the robot to perform discrete movements, with a set time for each.<br \/>\nIt 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.<\/p>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"conexion\"><\/p>\n<h2>CONECTING ROBOT<\/h2>\n<p><\/a><br \/>\nBTControl allows to control Bluetooth-paired robots.<br \/>\nThe &#8220;Conections&#8221; option from the Settings, launches the Bluetooth settings of your device, allowing pair devices.<br \/>\nPaired devices appear in the BTControl menu, to select easily which one to use.<\/p>\n<p>You can also check the &#8220;Auto-Connect&#8221; option, so the app will try to connect automatically with the last device connected.<\/p>\n<p>If the app connects automatically with a device and you want to connect to another device, un-check the &#8220;Auto-Connect&#8221; option.<\/p>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"problemas\"><\/p>\n<h2>TROUBLESHOOTING<\/h2>\n<p><\/a><\/p>\n<h3>The device I want to use is not listed on the menu<\/h3>\n<p>Use the Bluetooth settings to pair the device. If still does not appear try to restart the program.<\/p>\n<h3>The device does not connect properly<\/h3>\n<h3>Errors occur when sending signals<\/h3>\n<p>Try:<\/p>\n<ol>\n<li>From the Bluetooth settings, delete the device (un-pair it)\n<li>Reboot both devices\n<li>Re-pair the device<\/ol>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"desarrolladores\"><\/p>\n<h2>DEVELOPERS<\/h2>\n<p><\/a><br \/>\nThe robot must have a working Bluetooth module (<a href=\"http:\/\/guimi.net\/blogs\/hiparco\/category\/arduino\/\">examples on my website<\/a>).<br \/>\nBTControl sends out single-character signals that the robot must interpret.<br \/>\nSignals sent can be changed in the &#8220;Settings&#8221;, but if not modified are:<\/p>\n<ul>\n<li>Primo* Signals:\n<ul>\n<li>Forward (Red): V\n<li>Left (Blue): W\n<li>Right (Yellow): Y<\/ul>\n<li>Primo-like Signals (from the remote):\n<ul>\n<li>Stop (Green): X\n<li>Backward (Red): Z<\/ul>\n<li>Control wheel Signals:\n<ul>\n<li>Numbers 1 to 9, being 1 front-left, front 2, &#8230;, stop 5, &#8230;, 9 back-right<\/ul>\n<li>Function buttons:\n<ul>\n<li>A to J buttons send the corresponding character<\/ul>\n<\/ul>\n<p>[*] At Primo mode, pressing the red button (run), BTControl composes the programmed message and adds &#8216;0&#8217; at the end of the message.<\/p>\n<p>You can reset default values, on the settings, press the menu button on your device and select &#8220;Reset default values&#8221;.<\/p>\n<p><a name=\"template\"><\/p>\n<h3>Arduino Template code<\/h3>\n<p><\/a><br \/>\n<a href=\"\/imgs\/blog\/hiparco\/btcontrol\/BTControl.ino\">Download code<\/a><\/p>\n<pre class=\"brush: cpp; title: ; notranslate\" title=\"\">\r\n\/*\r\n ***********************************\r\n *            BTCONTROL            *\r\n ***********************************\r\n * 2014 - Guimi (http:\/\/guimi.net) *\r\n ***********************************\r\n *\r\n * Este programa implementa un robot controlado por bluetooth utilizando los comandos pre-definidos del programa\r\n * BTControl para Android (BTControl - 2014 Guimi - http:\/\/guimi.net)\r\n *\r\n * El programa requiere de un modulo Bluetooth HC-05 para la comunicacion\r\n *\r\n * El ciclo principal escucha las instrucciones recibidas por Bluetooth y si las reconoce las ejecuta\r\n *\r\n * Para DEBUG se debe configurar el modulo serial a 9600 baudios con &quot;Ambos NL &amp; CR&quot;\r\n *\r\n * 2014 - Guimi (http:\/\/guimi.net)\r\n *\r\n *\/\r\n\r\n\/\/ DEBUG\r\n\/\/----------\r\n#define DEBUG false \/\/ Indica si debemos realizar DEBUG mediante el puerto serie\r\n\r\n\r\n\/\/ LIBRERIAS\r\n\/\/----------\r\n#include &lt;SoftwareSerial.h&gt; \/\/Librer\u00eda que permite establecer comunicacion serie en pins diferentes al 0 y 1\r\n\r\n\r\n\/\/ CONSTANTES\r\n\/\/-----------\r\n#define BT_Rx 10 \/\/ Recepcion BT\r\n#define BT_Tx 11 \/\/ Transmision BT\r\n#define LED_ESTADO 13 \/\/ Pin del LED que marca el estado\r\n\r\n\r\n\/\/ VARIABLES\r\n\/\/----------\r\nint caracter; \/\/ Caracter recibido\r\n\r\n\r\n\/\/ MODULOS\r\n\/\/--------\r\nSoftwareSerial BT(BT_Tx,BT_Rx); \/\/ Inicializamos el BT, indicando los pines de Tx y Rx\r\n\r\n\r\n\/\/ FUNCION SETUP\r\n\/\/--------------\r\nvoid setup() {\r\n  \/\/ Definimos cada pin como entrada o salida\r\n  pinMode(LED_ESTADO,OUTPUT);\r\n\r\n  \/\/ Indicamos que aun no hemos iniciado\r\n  digitalWrite(LED_ESTADO, LOW);\r\n\r\n  \/\/ Esperamos a que este encendido el modulo BT\r\n  delay(500);\r\n  \/\/ Preparamos la comunicacion mediante el modulo BT\r\n  BT.begin(9600);\r\n  delay(500);\r\n  BT.flush();\r\n\r\n  \/\/ Preparamos la comunicacion mediante el puerto serie y el modulo BT\r\n  if (DEBUG) {\r\n    Serial.begin(9600);\r\n    \r\n    \/\/ Notificamos que estamos listos\r\n    Serial.write(&quot;Preparado:\\n&quot;);\r\n  }\r\n\r\n  \/\/ Indicamos el inicio\r\n  digitalWrite(LED_ESTADO, HIGH);\r\n\r\n}\r\n\r\n\r\n\/\/ FUNCION LOOP\r\n\/\/-------------\r\nvoid loop() {\r\n\r\n  \/\/ Si hay algo pendiente en el puerto Serial lo transmitimos\r\n  \/\/ de forma transparente al modulo BT (que lo envia directamente al aparato vinculado)\r\n  if (Serial.available()) {\r\n    \/\/ Escribimos en el puerto BT lo que leemos en el puerto serie\r\n    BT.write(Serial.read());\r\n  }\r\n\r\n\r\n  \/\/ Si hay algo pendiente en el puerto BT lo transmitimos\r\n  \/\/ de forma transparente al puerto serie y buscamos comandos conocidos\r\n  if (BT.available()) {\r\n    \/\/ Buscamos comandos conocidos\r\n    \/\/---------------------------- \r\n    \/\/ Leemos el puerto\r\n    caracter = BT.read();\r\n    \/\/ Escribimos en el puerto serie lo que leemos en el puerto BT\r\n    if (DEBUG) Serial.write(caracter);\r\n\r\n    switch (caracter) {\r\n      \/\/ CARACTER 0\r\n      \/\/------------------------------\r\n      case '0':\r\n        break;\r\n\r\n\r\n      \/\/ RUEDA DE CONTROL (MOVIMIENTO)\r\n      \/\/------------------------------\r\n      \/\/ Los ponemos los primeros porque necesitan la respuesta mas inmediata\r\n      case '1':\r\n        break;\r\n      case '2':\r\n        break;\r\n      case '3':\r\n        break;\r\n      case '4':\r\n        break;\r\n      case '5':\r\n        break;\r\n      case '6':\r\n        break;\r\n      case '7':\r\n        break;\r\n      case '8':\r\n        break;\r\n      case '9':\r\n        break;\r\n\r\n        \r\n      \/\/ BOTONES DE FUNCION (A-J)\r\n      \/\/------------------------------\r\n      case 'A':\r\n        break;\r\n      case 'B':\r\n        break;\r\n      case 'C':\r\n        break;\r\n      case 'D':\r\n        break;\r\n      case 'E':\r\n        break;\r\n      case 'F':\r\n        break;\r\n      case 'G':\r\n        break;\r\n      case 'H':\r\n        break;\r\n      case 'I':\r\n        break;\r\n      case 'J':\r\n        break;\r\n\r\n\r\n      \/\/ BOTONES PRIMO Y SIMILARES\r\n      \/\/------------------------------\r\n      case 'V':\r\n        break;\r\n      case 'W':\r\n        break;\r\n      case 'X':\r\n        break;\r\n      case 'Y':\r\n        break;\r\n      case 'Z':\r\n        break;\r\n\r\n    \r\n      default: \r\n        break;\r\n\r\n    }\r\n\r\n  }\r\n}\r\n<\/pre>\n<p><a href=\"\/imgs\/blog\/hiparco\/btcontrol\/BTControl.ino\">Download code<\/a><\/p>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n<hr width=\"50%\">\n<a name=\"creditos\"><\/p>\n<h2>ABOUT<\/h2>\n<p><\/a><br \/>\n<a href=\"http:\/\/guimi.net\"><img decoding=\"async\" src=\"\/imgs\/blog\/hiparco\/btcontrol\/guimi.png\"><\/a><br \/>\nBTControl by <a href=\"http:\/\/guimi.net\">G\u00fcimi<\/a><\/p>\n<p>Background image (<a href=\"http:\/\/www.publicdomainpictures.net\/view-image.php?image=26031&#038;picture=light-wood-texture\">light_wood_texture<\/a>) by Petr Kratochvil.<\/p>\n<p><a href=\"http:\/\/www.primo.io\">Primo<\/a> by <a href=\"http:\/\/solidlabs.co\/\">Solid Labs<\/a><\/p>\n<p><a href=\"#menu\">Go to index<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>BTCONTROL [SPANISH VERSION] INTRODUCTION BTControl &#8211; PRIMO BTControl &#8211; REMOTE CONECTING ROBOT TROUBLESHOOTING DEVELOPERS ARDUINO TEMPLATE CODE ABOUT 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&#8217;s open-source! Check the code! It has [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1734,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1733","page","type-page","status-publish","has-post-thumbnail","hentry"],"_links":{"self":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/pages\/1733","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/comments?post=1733"}],"version-history":[{"count":14,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/pages\/1733\/revisions"}],"predecessor-version":[{"id":1758,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/pages\/1733\/revisions\/1758"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/media\/1734"}],"wp:attachment":[{"href":"http:\/\/guimi.net\/blogs\/hiparco\/wp-json\/wp\/v2\/media?parent=1733"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}