This BlinkM LED is controlled via an Android smartphone, using a virtual joystick
More info re Joystick Bluetooth Commander application in the Networking section
Enjoy
This BlinkM LED is controlled via an Android smartphone, using a virtual joystick
More info re Joystick Bluetooth Commander application in the Networking section
Enjoy
Cool, is there an .ino associated with this to look at?
Cool, is there an .ino associated with this to look at?
Sure
// AndroBlinkM V1.2
// Arduino test sketch for Joystick BT Commander
// Drive a BlinkM LED
// * BlinkM connections to Arduino
// * GND Analog 2
// * +5V Analog 3
// * SDA Analog 4
// * SCK Analog 5
#include "Wire.h"
#include "BlinkM_funcs.h"
#define DEBUG true
#define blinkm_addr 0x00
#define ledPin 13 // LED pin
#define STX 0x02
#define ETX 0x03
int i=0;
int cmd[5] = {9, 9, 9, 9, 9};
void setup() {
Serial.begin(57600); // Adjust to your specific BT Board
pinMode(ledPin, OUTPUT);
BlinkM_beginWithPower();
BlinkM_stopScript( blinkm_addr ); // turn off BlinkM startup script
BlinkM_fadeToRGB( blinkm_addr, 0x00, 0x00, 0x00);
}
void loop() {
if(Serial.available()) { // Data received from smartphone
delay(5);
cmd[0] = Serial.read();
if(cmd[0] == STX) {
i=1;
while(Serial.available() && ((cmd[i]=Serial.read()) != ETX)) {
if(i>3) break;
i++;
}
}
if(i==2) setLED(cmd[1]);
if(i==3) setBlinkM(cmd[1], cmd[2]);
}
delay(5);
}
void setBlinkM(int hue, int bright) {
hue = map(hue, 10, 110, 0, 255);
bright = map(bright, 10, 110, 0, 255);
bright = constrain(bright, 7, 255);
if(DEBUG) { Serial.print(hue); Serial.print(", "); Serial.println(bright); } // ** DEBUG **
BlinkM_fadeToHSB(blinkm_addr, hue, 255, bright); // set blinkM hue & brightness
delay(20);
}
void setLED(int LEDstatus) {
switch (LEDstatus) {
case '1':
if(DEBUG) Serial.println("Button: ON"); // ** DEBUG **
digitalWrite(ledPin, HIGH);
BlinkM_setRGB( blinkm_addr, 0xff, 0xff, 0xff);
break;
case '2':
if(DEBUG) Serial.println("Button: OFF"); // ** DEBUG **
digitalWrite(ledPin, LOW);
BlinkM_setRGB( blinkm_addr, 0x00, 0x00, 0x00);
break;
}
}
loop() code is identical as the pan/tilt project shown in the Robotic Section
More info for blinkM here
Arduino sketch needs to be modified for Joystick Bluetooth Commander V3.X
(modified communication protocol)
More details here
Joystick Bluetooth Commander is now Version 5.1
Code should be updated with new communication protocol
More info here and here