fbpx

KAI robot is an amazing platform for mobility IoT. In this guide you will learn how to make a simple IoTaaP code for controlling your KAI robot via Bluetooth.

First you have to create a new project and select IoTaaP platform, you can find how to do that by checking our Environment Setup instructions. After successful assembly of you KAI robot and connectiong all the servo motors, you can now proceed with programming.

KAI robot must use external battery power supply, connected to VSYS and GND pins in order to work properly. Battery or external supply voltage must not exceed 4.5V !

The code below will initialize servo KAI robot and attach servo motors to pins. After initialization the code will move servo motors to initial position and open Bluetooth connection. You will se device “KAI” in your Android Bluetooth devices list (you have to pair your phone with KAI).

In the loop, code will wait for character ‘k’, and if character ‘k’ is received KAI will walk for 1 cycle.

This is really basic example of remote controll via Bluetooth, but feel free to improve this code, add more features and share it with community!

#define ENABLE_KAI
#define ENABLE_BTSERIAL

#include "IoTaaP.h"
#include "lib/3rd_party/Servo/Servo.h"

IoTaaP iotaap; // IoTaaP library

void setup()
{
  iotaap.kai.init(16, 17, 4, 13); // Setup KAI robot servo pins
  iotaap.kai.home(); // Move servo motors to initial position
  iotaap.btSerial.begin("KAI"); // Open Bluetooth connection 
}

void loop()
{
  if (iotaap.btSerial.available()) // Check if data is available on serial receiver
  {
    if (iotaap.btSerial.read() == 'k') // Check if character 'k' is received
    {
      iotaap.kai.walk(12, 1, 0); // Walk if true
    }
  }
  delay(20);
}

In order to send your commands to KAI, you have to download some Bluetooth terminal application

serial-bluetooth-terminal-app

Open your application, connect with KAI and send character ‘k’. Enjoy playing with your robot by adding more commands.