Arduino Bluetooth LED

Control Arduino LED with RoboRemo app

Arduino Bluetooth LED

This page explains how to remote control the Arduino LED on pin 13 using an Android phone with RoboRemo app.

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

Introduction

This is a basic example of how to use RoboRemo to control Arduino. Note that there is no need for special library, as the app is sending raw data. Anyone familiar with Arduino programming will find it very easy to modify this project to do more advanced stuff.

Steps:

1.
Upload the code to your Arduino:

// Control Arduino LED via Bluetooth
// using RoboRemo app
// www.roboremo.com

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

// Arduino UNO already has an LED attached to pin 13

#include <SoftwareSerial.h>  

int bluetoothTx = 2;
int bluetoothRx = 3;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

int led = 13;

char cmd[100];
int cmdIndex;

void exeCmd() {
  
  // "led" is the led id
  
  if(strcmp(cmd, "led 0")==0) digitalWrite(led, LOW);
  if(strcmp(cmd, "led 1")==0) digitalWrite(led, HIGH);
}

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

  bluetooth.begin(115200); // Bluetooth default baud is 115200
  
  bluetooth.print("$");
  bluetooth.print("$");
  bluetooth.print("$"); // enter cmd mode
  delay(250);  
  bluetooth.println("U,9600,N"); // change baud to 9600
  
  bluetooth.begin(9600);
  
  pinMode(led, OUTPUT);
  digitalWrite(led, LOW);
  
  cmdIndex = 0;
}

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

2.
Connect the Bluetooth module to the Arduino like this:

arduino-bluetooth-led-schematic.jpg

3.
Connect your Arduino to USB or to a DC power supply.

4.
Configure the RoboRemo interface and enjoy :)