Things used in this project

Hardware components:
Ardgen 101
Arduino 101 & Genuino 101
×1
DFRobot RGB LED breakout
×1
11026 02
Jumper wires (generic)
×1
12002 04
Breadboard (generic)
×1
DFRobot Gravity: IO Expansion Shield
×1
Software apps and online services:
Ide web
Arduino IDE
App Inventor

Code

App InventorScratch
Ger RGB data of the touch point, then send to Arduino 101. sorry no item for App Inventor .aia file~
No preview (download only).
Arduino 101Arduino
Receiving data from Android phone and change the RGB LED light intensity.
#include <CurieBLE.h>
#include <stdlib.h>
#define LEDr 9
#define LEDg 6
#define LEDb 3

BLEPeripheral blePeripheral;  
//BLE Peripheral Device (the board you're programming)
BLEService ControlLED("19B10010-E8F2-537E-4F6C-D104768A1214"); 
//initialize a BLE Service

// BLE LED Switch Characteristic - custom 128-bit UUID, read and writable by central
BLEUnsignedIntCharacteristic LEDStatus("19B10011-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite  );

int incom = 0;
int r, g, b ;

void setup() {
  Serial.begin(9600);

  // set advertised local name and service UUID:
  blePeripheral.setLocalName("ControlLED");
  blePeripheral.setAdvertisedServiceUuid(ControlLED.uuid());

  // add service and characteristic:
  blePeripheral.addAttribute(ControlLED);
  blePeripheral.addAttribute(LEDStatus);

  // begin advertising BLE Light service:
  blePeripheral.begin();

  Serial.println("BLE RGBLED control.");

  // set Light pin to output mode
  pinMode(LEDr, OUTPUT);
  pinMode(LEDg, OUTPUT);
  pinMode(LEDb, OUTPUT);
}

void loop() {
  // listen for BLE peripherals to connect:
  BLECentral central = blePeripheral.central();
  // if a central is connected to peripheral:
  if (central) {
    Serial.print("Connected to central: ");
    // print the central's MAC address:
    Serial.println(central.address());

    // while the central is still connected to peripheral:
    while (central.connected()) {
      //Serial.println(LEDStatus.written());
      if (LEDStatus.written())
      {
        incom = LEDStatus.value();//take 110225101 for exmaple
        r = incom / 1000000 ;//110
        g = (incom / 1000 - r * 1000) ; //110225-110000=225
        b = (incom - r * 1000000 - g * 1000) ; //110225101-110000000-2250000=101
        Serial.println(incom);
        Serial.println(r);
        Serial.println(g);
        Serial.println(b);  //show RGB data on serial monitor
        analogWrite(LEDr, r);
        analogWrite(LEDg, g);
        analogWrite(LEDb, b); //Light up LED
        delay(10);
      }
    }
    digitalWrite(LEDr, LOW);
    digitalWrite(LEDg, LOW);
    digitalWrite(LEDb, LOW);  //LED turn off
    delay(100);
  }

  // when the central disconnects, print it out:
  Serial.print(F("Disconnected from central: "));
  Serial.println(central.address());
}

Credits

Replications

Did you replicate this project? Share it!

I made one

Love this project? Think it could be improved? Tell us what you think!

Give feedback

Comments

Similar projects you might like

Smart Garden
Intermediate
  • 1,073
  • 12

Smart Garden is plant environmental monitoring system.

Intel Curie TinyTILE Dress: Accelerometer + Optical Fibers
Intermediate
  • 331
  • 10

Full instructions

A dress using Intel Curie accelerometer on TinyTILE and its small form factor to control colors of the optical fibers with arm movements.

Arduino Bike Blink Lights
Intermediate
  • 483
  • 8

Protip

Arduino Nano bike bag signals, controlled by a wireless (RF) RC attached to front handle.

WiDC: Wi-Fi-Controlled FPV Robot
Intermediate
  • 5,107
  • 32

Full instructions

What about using a Wi-Fi remote-controlled robot for exploring your surroundings, reaching inaccessible places, spying and take pictures?

Sienci Mill One - Simple and Affordable Desktop CNC
Intermediate
  • 7,826
  • 37

Full instructions

The Sienci Mill One is a powerful, open source desktop CNC machine to turn your digital 3D designs into real physical objects.

MPU9250-Data-Visualization
Intermediate
  • 343
  • 6

Protip

A useful tool to visualize at real time data of the MPU9250 sent through a COM port.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login
Feedback