Conor Doheny
Published © GPL3+

Scuplture project

This project pulls data from the HHS on unaccompanied kids who were apprehended at the US boder and represents the amount taken into custody

IntermediateFull instructions provided48
Scuplture project

Things used in this project

Hardware components

SG90 Micro-servo motor
SG90 Micro-servo motor
Might need stronger servo depending on the weight of the gates.
×2
LilyPad Rainbow LED (strip of 7 colors)
SparkFun LilyPad Rainbow LED (strip of 7 colors)
Couldnt get them functional.
×4

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE
HHS portal

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Enclosure

Popsicle sticks used on the floor. Gates were made of a lightweight metal mesh and 2 inch wooden sticks to support it. Tin foil was used to represent the thermal blankets. and the hole in the back is for more led lights, representing the bright white lights used similar to a doctors office.

Schematics

LED lights wiring

Photon wiring and servos

Code

Full sculpture project code

C/C++
This code is used to draw data from the HHS integration, which than goes to the motors to visually represent the data.
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>

// Include Particle Device OS APIs
#include "Particle.h"

#if (PLATFORM_ID == 32)
// MOSI pin MO
#define PIXEL_PIN SPI
// MOSI pin D2
// #define PIXEL_PIN SPI1
#else // #if (PLATFORM_ID == 32)
#define PIXEL_PIN D15
#endif
#define PIXEL_COUNT 25
#define PIXEL_TYPE WS2812B
// Let Device OS manage the connection to the Particle Cloud
SYSTEM_MODE(AUTOMATIC);

// Show system, cloud connectivity, and application logs over USB
// View logs with CLI using 'particle serial monitor --follow'
SerialLogHandler logHandler(LOG_LEVEL_INFO);
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
Servo myServo;
Servo myServo2;

int analogPin = A2;
int analogPin2 = A5;
// setup() runs once, when the device is first turned on
void setup() {
  // Put initialization like pinMode and begin functions here
    Particle.subscribe("hook-response/cbpdata", multiValueHandler);
    Serial.begin(9600);
    strip.begin();
    strip.clear();
    myServo.attach(analogPin);
    myServo2.attach(analogPin2);
    myServo.write(0);
    myServo2.write(180);
    
}

// loop() runs over and over again, as quickly as it can execute.
void loop() {
  // The core of your code will likely live here.

  // Example: Publish event to cloud every 10 seconds. Uncomment the next 3 lines to try it!
  // Log.info("Sending Hello World to the cloud!");
  // Particle.publish("Hello world!");
  // delay( 10 * 1000 ); // milliseconds and blocking - see docs for more info!
}

void multiValueHandler(const char *event, const char *data){
    
    String dataStr = String(data);
    char strBuffer[11] = "";
    dataStr.toCharArray(strBuffer, 11);
    
    String children_in_cbp = strtok(strBuffer, ",");
    int child_cbp = strtol(children_in_cbp, NULL, 10);
    Serial.println(data);
    Serial.println("Children in CBP facilities: " + children_in_cbp);
    int cbplights_length = map(child_cbp, 0, 30, 0, 22); 
    
    String children_transferred = strtok(NULL, ",");
    Serial.println("Children transferred out of CBP facilities: " + children_transferred);
    
    char *childrenStr = strtok(strBuffer, ",");
    if (childrenStr == nullptr){
    Serial.println("Error parsing children_transferred");
    return;
    }
    int childrenTransferred = atoi(childrenStr);
    String children_freed = strtok(NULL, ",");
    int freechildren = strtol(children_freed, NULL, 10);
    int skycolor =  map(freechildren, 0, 200, 0, 255);
    Serial.println("Children discharged from HHS facilities: " + children_freed);
    Serial.println("Sky val: " + skycolor);
    for(int i = 0; i < cbplights_length; i++)
        {
            strip.setPixelColor(i, 255, 255, 255);
        }
    for(int i = 23; i < PIXEL_COUNT; i++)
    {
        strip.setPixelColor(i, 0, 0, skycolor, 255);
    }
    strip.show();
    
  
    Serial.print("Children transferred (int): ");
    Serial.println(childrenTransferred);

  // Set servo angles based on the data
    if (childrenTransferred < 5){
        myServo.write(15);
        myServo2.write(165);
    }
    else if (childrenTransferred > 5 && childrenTransferred < 30) {
        myServo.write(0);
        myServo2.write(180);
    }
    else if (childrenTransferred >= 30) {
        myServo.write(90);
        myServo2.write(90);
    }
}

Credits

Conor Doheny
2 projects • 0 followers
Thanks to Sofie Miniscalco.

Comments