DFR0748 Kitty's Flower

Introduction

Kitty's Flower is a pair of Bluetooth wearable brooches. Jointly created by Art by Physicist and DFRobot, they are specially designed for wearable application scenarios, integrated power management system, RGB LED lights, accelerometer, sensors, vibration, and touch. Support Arduino and Scratch programming, and can be used as the core intelligent control unit for wearable products, interactive art installations, and new accessories. Two are matched as a pair, and various effects can be programmed by users. The factory-set functions are programmed for the above-mentioned scenario. Companion brooches match the Flower outfit (top, shorts and mask cover) with hand digital painting on fabric and 3D printed flowers on tulle.

Specification

Board Overview

DFR0748 Overview

Num Label Description
1 Vibration Motor D5
2 Touch D6
3 RGB LED D9
4 LIS2DH 3-Axis Accelerometer I2C

Tutorial

Kitty Flower integrates multiple functions, we will show them one by one below, but in actual use, please upgrade Kitty Flowers Demo separately: KittyMother and KittyChild two demos to complete the pairing and connection. The two demos will automatically set the master/slave status of the motherboards, and then read the Bluetooth RSSI field strength value to determine the distance between each other. click to download Kitty's Flower Demo. Here are the other functions.

Requirements

Sample Code for Vibration Motor

#define VMPIN      5     //Vibration motor pin

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(VMPIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(VMPIN, HIGH);   // turn the Motor on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(VMPIN, LOW);    // turn the Motor off by making the voltage LOW
  delay(1000);                       // wait for a second
}

Sample Code for Touch

#define TOUCHPIN   6

void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(115200);
  // make the pushbutton's pin an input:
  pinMode(TOUCHPIN, INPUT);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input pin:
  int touchState = digitalRead(TOUCHPIN);
  // print out the state of the button:
  Serial.println(touchState);
  delay(10);        // delay in between reads for stability
}

Open the serial port, touch the stamen, the serial port will output high level; otherwise, it outputs low level

Sample Code for RGB LED

Click to the Download Link (About how to install the library?)

  #include <Adafruit_NeoPixel.h>

    #define PIN 9     //The signal pin connected with Arduino
    #define LED_COUNT 60 // the amount of the leds of your strip

    // Create an instance of the Adafruit_NeoPixel class called "leds".
    // That'll be what we refer to from here on...
    Adafruit_NeoPixel leds = Adafruit_NeoPixel(LED_COUNT, PIN, NEO_GRB + NEO_KHZ800);

    void setup()
    {
      leds.begin();  // Call this to start up the LED strip.
      clearLEDs();   // This function, defined below, turns all LEDs off...
      leds.show();   // ...but the LEDs don't actually update until you call this.
    }

    void loop()
    {
        for (int i=0; i<LED_COUNT; i++)
      {
        rainbow(i);
        delay(10);  // Delay between rainbow slides
      }
    }


    // Sets all LEDs to off, but DOES NOT update the display;
    // call leds.show() to actually turn them off after this.
    void clearLEDs()
    {
      for (int i=0; i<LED_COUNT; i++)
      {
        leds.setPixelColor(i, 0);
      }
    }

    // Prints a rainbow on the ENTIRE LED strip.
    //  The rainbow begins at a specified position.
    // ROY G BIV!
    void rainbow(byte startPosition)
    {
      // Need to scale our rainbow. We want a variety of colors, even if there
      // are just 10 or so pixels.
      int rainbowScale = 192 / LED_COUNT;

      // Next we setup each pixel with the right color
      for (int i=0; i<LED_COUNT; i++)
      {
        // There are 192 total colors we can get out of the rainbowOrder function.
        // It'll return a color between red->orange->green->...->violet for 0-191.
        leds.setPixelColor(i, rainbowOrder((rainbowScale * (i + startPosition)) % 192));
      }
      // Finally, actually turn the LEDs on:
      leds.show();
    }

    // Input a value 0 to 191 to get a color value.
    // The colors are a transition red->yellow->green->aqua->blue->fuchsia->red...
    //  Adapted from Wheel function in the Adafruit_NeoPixel library example sketch
    uint32_t rainbowOrder(byte position)
    {
      // 6 total zones of color change:
      if (position < 31)  // Red -> Yellow (Red = FF, blue = 0, green goes 00-FF)
      {
        return leds.Color(0xFF, position * 8, 0);
      }
      else if (position < 63)  // Yellow -> Green (Green = FF, blue = 0, red goes FF->00)
      {
        position -= 31;
        return leds.Color(0xFF - position * 8, 0xFF, 0);
      }
      else if (position < 95)  // Green->Aqua (Green = FF, red = 0, blue goes 00->FF)
      {
        position -= 63;
        return leds.Color(0, 0xFF, position * 8);
      }
      else if (position < 127)  // Aqua->Blue (Blue = FF, red = 0, green goes FF->00)
      {
        position -= 95;
        return leds.Color(0, 0xFF - position * 8, 0xFF);
      }
      else if (position < 159)  // Blue->Fuchsia (Blue = FF, green = 0, red goes 00->FF)
      {
        position -= 127;
        return leds.Color(position * 8, 0, 0xFF);
      }
      else  //160 <position< 191   Fuchsia->Red (Red = FF, green = 0, blue goes FF->00)
      {
        position -= 159;
        return leds.Color(0xFF, 0x00, 0xFF - position * 8);
      }
    }

Sample Code for Accelerometer

Click to the Download Link (About how to install the library?)

#include <Wire.h>
#include <DFRobot_LIS2DH12.h>

DFRobot_LIS2DH12 LIS; //Accelerometer

void setup() {
  Wire.begin();
  Serial.begin(115200);
  while (!Serial);
  delay(100);

  // Set measurement range
  // Ga: LIS2DH12_RANGE_2GA
  // Ga: LIS2DH12_RANGE_4GA
  // Ga: LIS2DH12_RANGE_8GA
  // Ga: LIS2DH12_RANGE_16GA
  while (LIS.init(LIS2DH12_RANGE_16GA) == -1) { //Equipment connection exception or I2C address error
    Serial.println("No I2C devices found");
    delay(1000);
  }
}

void loop() {
  acceleration();
}

/*!
    @brief Print the position result.
*/
void acceleration(void)
{
  int16_t x, y, z;

  delay(100);
  LIS.readXYZ(x, y, z);
  LIS.mgScale(x, y, z);
  Serial.print("Acceleration x: "); //print acceleration
  Serial.print(x);
  Serial.print(" mg \ty: ");
  Serial.print(y);
  Serial.print(" mg \tz: ");
  Serial.print(z);
  Serial.println(" mg");
}

Result

More Documents

DFshopping_car1.png Get Kitty Flower from DFRobot Store or DFRobot Distributor.

Turn to the Top