Skip to content

Instantly share code, notes, and snippets.

@yoshimax
Created May 5, 2013 00:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshimax/5519217 to your computer and use it in GitHub Desktop.
Save yoshimax/5519217 to your computer and use it in GitHub Desktop.
Arduino BLEShield SDK Chat_Sketch Text send 'r' BlinkM fade to 'Red' Sketch https://github.com/RedBearLab/Release/tree/master/BLEShield
#include <Arduino.h>
#include <SPI.h>
#include "ble.h"
#include <Wire.h>
#include "BlinkM_funcs.h"
#define blinkm_addr 0x00
void setup()
{
SPI.setDataMode(SPI_MODE0);
SPI.setBitOrder(LSBFIRST);
SPI.setClockDivider(SPI_CLOCK_DIV16);
SPI.begin();
ble_begin();
Serial.begin(57600);
// blinkM Setup
pinMode(13,OUTPUT);
BlinkM_beginWithPower();
BlinkM_stopScript( blinkm_addr ); // turn off startup script
}
int val;
void loop()
{
while ( ble_available() ){
if( ble_available()>0){
val=ble_read();
}
if(val=='w'){
BlinkM_fadeToRGB(blinkm_addr,0xff,0xff,0xff);
digitalWrite(13,HIGH);
}
if(val=='r'){
BlinkM_fadeToRGB(blinkm_addr,0xff,0x00,0x00);
digitalWrite(13,HIGH);
}
if(val=='b'){
BlinkM_fadeToRGB(blinkm_addr,0x00,0x00,0x00);
digitalWrite(13,LOW);
}
}
ble_do_events();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment