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

3D Printer Filament Monitor for Arduino
Intermediate
  • 66
  • 3

The ability to dynamically measure the plastic material (filament) in use by a 3D printer includes some interesting requirements.

Starry Night Prom
Intermediate
  • 2,603
  • 22

How did I stand out at prom? In a light up dress of course!

Make a Binary Half Adder
Intermediate
  • 47
  • 3

Protip

Binary data is 0 and 1, two numbers to represent the number. In decimal, we know that "1 + 1 = 2". So what is the operation in binary?

Wireless Light Switch Manipulator
Intermediate
  • 443
  • 4

Full instructions

Have you ever gotten out of bed just to turn off or on the light switch? Well worry no more!

The Trump Button
Intermediate
  • 1,418
  • 9

Full instructions

The famous connected button to order your favorite drink using Sigfox network.

Voice Controlled Home Automation Using Arduino via Bluetooth
Intermediate
  • 22
  • 1

We can switch on and off any home appliance through voice via Bluetooth, using Arduino via Bluetooth.

ProjectsCommunitiesTopicsContestsLiveAppsBetaFree StoreBlogAdd projectSign up / Login