Kitty Yeung
Published © CC BY-SA

Saturn - Adafruit Flora, DFRobot, Arduino

How to make a dress representing Saturn? The planets and satellites light up when the ring appears.

IntermediateFull instructions provided12 hours2,690

Things used in this project

Hardware components

Flora
Adafruit Flora
×1
Gravity: I2C BMI160 6-Axis Inertial Motion Sensor
DFRobot Gravity: I2C BMI160 6-Axis Inertial Motion Sensor
×1
DFRobot LED String Lights
×1
DFRobot Accessories Polymer Lithium Ion Battery 1000mAh
Or any 3.7 V Lithium Ion battery with a JST connector.
×1
Painting of Saturn on fabrics
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Sewing machine (generic)
zipper (generic)

Story

Read more

Schematics

Accelerometer on microcontroller

Learn more here: https://wiki.dfrobot.com/Gravity__BMI160_6-Axis_Inertial_Motion_Sensor_SKU__SEN0250

LED string on microcontroller

Learn more here: https://wiki.dfrobot.com/LED_String_Lights__Colorful__SKU__DFR0439

Code

Accelerometer angle-controlled LEDs

Arduino
Learn more here: https://wiki.dfrobot.com/Gravity__BMI160_6-Axis_Inertial_Motion_Sensor_SKU__SEN0250
#include <DFRobot_BMI160.h>
int t;
#define  Light_string 6

DFRobot_BMI160 bmi160;
const int8_t i2c_addr = 0x69;
void setup(){
  Serial.begin(115200);
  delay(100);
    pinMode( Light_string, OUTPUT);
  
  //init the hardware bmin160  
  if (bmi160.softReset() != BMI160_OK){
    Serial.println("reset false");
    while(1);
  }
  
  //set and init the bmi160 i2c address
  if (bmi160.I2cInit(i2c_addr) != BMI160_OK){
    Serial.println("init false");
    while(1);
  }
}


void loop() {

  int i = 0;
  int rslt;
  int16_t accelGyro[6]={0}; 
  
  //get both accel and gyro data from bmi160
  //parameter accelGyro is the pointer to store the data
  rslt = bmi160.getAccelGyroData(accelGyro);
  
  Serial.print(rslt);Serial.print("\t");

    // read accelerometer:
  float rawX = accelGyro[3]*3.14/180.0;
  float rawY = accelGyro[4]*3.14/180.0;
  float rawZ = accelGyro[5]*3.14/180.0;

  Serial.print(rawX);Serial.print("\t");
  Serial.print(rawY);Serial.print("\t");
  Serial.print(rawZ);Serial.print("\t");

float angle = atan2(rawZ, rawY); // the funtion atan2() converts x and y forces into an angle in radians.  cool!  Output is -3.14 to 3.14
  Serial.print(abs(angle));Serial.print("\t\n");
  
  if (abs(angle) > 0.2 && abs(angle) < 2.8) { //  digital pins are down
    ///  turn lights off in this position
        analogWrite( Light_string, 255);

  }else{
    analogWrite( Light_string, LOW);
    }
delay(500);
}

Credits

Kitty Yeung

Kitty Yeung

19 projects • 184 followers
Physicist/Artist/Musician/Fashion Designer/Engineer www.kittyyeung.com

Comments