Receive images in RoboRemo

Send images from Arduino and display them in RoboRemo

Receive images in RoboRemo

RoboRemo can receive and display images in various formats including JPG, PNG, BMP and raw pixel data. More information can be found in the app. manual. In this demo I use Arduino to generate and send small 3x5 px raw images.

Materials needed:
- Arduino UNO (or similar) + USB cable for it
- BlueSMiRF module or similar
- DC adapter for Arduino
- wires
- Android phone with RoboRemo app installed

Introduction

Image item in RoboRemo can be used to receive video frames from a camera, custom graphics or plots, or other cool stuff. You build the inside an array in your Arduino code, then send it to RoboRemo, so you have pixel-level control.
Local images can also be imported in RoboRemo interface for background or fancy buttons.

In this demo I show a basic example of receiving raw images generated by the Arduino.

Steps:

1.
Upload this code to your Arduino:

// Sending images from Arduino to RoboRemo
// www.roboremo.com

// Hardware setup:
// BT module   Arduino
// GND ------- GND
// VCC ------- 5V
// TX-O ------ pin0
// RX-I ------ pin1


int on = 0; // off

char cmd[100];
int cmdIndex;


boolean cmdStartsWith(char *st) {
  for(int i=0; ; i++) {
    if(st[i]==0) return true;
    if(cmd[i]==0) return false;
    if(cmd[i]!=st[i]) return false;;
  }
  return false;
}


void exeCmd() {
  
  if( cmdStartsWith("on") ) on = 1;
  if( cmdStartsWith("off") ) on = 0;
     
}

// 3 images for tests:

long img1[] = {0x000000, 0xFF0000, 0x000000,
               0xFF0000, 0xFF0000, 0x000000,
               0x000000, 0xFF0000, 0x000000,
               0x000000, 0xFF0000, 0x000000,
               0xFF0000, 0xFF0000, 0xFF0000};
               
long img2[] = {0x00FF00, 0x00FF00, 0x00FF00,
               0x000000, 0x000000, 0x00FF00,
               0x00FF00, 0x00FF00, 0x00FF00,
               0x00FF00, 0x000000, 0x000000,
               0x00FF00, 0x00FF00, 0x00FF00};  
  
long img3[] = {0x0000FF, 0x0000FF, 0x0000FF,
               0x000000, 0x000000, 0x0000FF,
               0x000000, 0x0000FF, 0x0000FF,
               0x000000, 0x000000, 0x0000FF,
               0x0000FF, 0x0000FF, 0x0000FF};                





int a = 1;

void sendImg() {
  
  long *img;
  
  if(a==1) img = img1;
  if(a==2) img = img2;
  if(a==3) img = img3;
  
  a++;
  if(a==4) a = 1;
  
  
  Serial.print("img 45\n"); // img is the id, 45 is the image size in Bytes
  
  // sending the image data:
  // (the image item in RoboRemo has the id "img"
  // and the format "RGB_888(3,5)"  )
  for(int i=0; i<15; i++) {
    long pixelColor = img[i];
    Serial.write(pixelColor>>16); // red
    Serial.write(pixelColor>>8); // green
    Serial.write(pixelColor); // blue
  }

}



void setup() {
  
  delay(500); // wait for bluetooth module to start

  Serial.begin(115200); // BlueSMiRF default baud is 115200
  
  cmdIndex = 0;
}



void loop() {
  
  while(Serial.available()) {
    
    char c = (char)Serial.read();
    
    if(c=='\n') {
      cmd[cmdIndex] = 0;
      exeCmd();  // execute the command
      cmdIndex = 0; // reset the cmdIndex
    } else {      
      cmd[cmdIndex] = c;
      if(cmdIndex<99) cmdIndex++;
    }
    
  }
  
  if(on) {
    sendImg();
    delay(333);
  }
  
}

2.
Connect the Bluetooth module to the Arduino as described in the sketch hardware setup.

3.
Power the Arduino with the DC adapter.

4.
Open RoboRemo, build the interface and enjoy :)