fiona
Published

Computational Sculpture

A art sculpture that reacts once a day to new arrest data being pulled from the Chicago Data Portal.

BeginnerShowcase (no instructions)11
Computational Sculpture

Things used in this project

Hardware components

Photon
Particle Photon
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Male/Female Jumper Wires
Male/Female Jumper Wires
×1
SparkFun Snappable Protoboard
SparkFun Snappable Protoboard
×1
Stepper Motor
Digilent Stepper Motor
×1
RGBW LED Chips 100 Pcs
×8
Hook Up Wire Kit, 22 AWG
Hook Up Wire Kit, 22 AWG
×1
Connector Adapter, DC Power - 2.1mm
Connector Adapter, DC Power - 2.1mm
×1
Female Header 8 Position 1 Row (0.1")
Female Header 8 Position 1 Row (0.1")
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Plier, Cutting
Plier, Cutting
Soldering iron (generic)
Soldering iron (generic)
Solder Wire, Lead Free
Solder Wire, Lead Free
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires
Wire Stripper & Cutter, 32-20 AWG / 0.05-0.5mm² Solid & Stranded Wires

Story

Read more

Code

Code (General View)

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

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

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

// Let Device OS manage the connection to the Particle Cloud
SYSTEM_MODE(AUTOMATIC);

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#if (PLATFORM_ID == 32)
// MOSI pin MO
//#define PIXEL_PIN SPI
// MOSI pin D2
#define PIXEL_PIN SPI
#else // #if (PLATFORM_ID == 32)
#define PIXEL_PIN A5
#endif
#define PIXEL_COUNT 4
#define PIXEL_TYPE WS2812B

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

// Show system, cloud connectivity, and application logs over USB
// View logs with CLI using 'particle serial monitor --follow'
SerialLogHandler logHandler(LOG_LEVEL_INFO);
// Set up for the Stepper Test
const int stepsPerRevolution = 2048; 
#define IN1 2
#define IN2 3
#define IN3 4
#define IN4 5

Stepper myStepper(stepsPerRevolution, IN1, IN3 , IN2, IN4);

int val=1000; 
int lastVal=1000; 
int currTime=0; 
int currMin=0; 
int currHour=0; 

// setup() runs once, when the device is first turned on
void setup() {
strip.begin();
strip.show(); 
Serial.begin(9600);
myStepper.setSpeed(10);
Time.zone(-5); 
Particle.subscribe(System.deviceID() + "/hook-response/Arrest/", myHandler, MY_DEVICES);
}

// will turn the motor 
void turn (){ 
    myStepper.step(2048);
} 

void back (){ 
    myStepper.step(-2048);
} 

// will call time 
int callTime(){ 
currHour= Time.hour()*60; 
currMin= Time.minute(); 
currTime = currHour + currMin;
return currTime; 
} 

void compare(){
if (val != lastVal){
   lastVal= val; 
    light(); 
    turn(); 
    back(); 
    off(); 
    }
}

void compTime(){ 
    if (currTime == 601){ 
        Particle.publish("Arrest");
    } 
} 
        
void light(){ 
    for(int i = 0; i < PIXEL_COUNT; i++) {
    strip.setPixelColor(i, strip.Color(255, 213, 128, 0)); // white 
    strip.setBrightness(90);

  }

  strip.show();
  delay(1000);
} 

void off(){ 
     for(int i = 0; i < PIXEL_COUNT; i++) {
    strip.setPixelColor(i, strip.Color(0,0,0,0)); // white 
    }
  strip.show();
  delay(1000);
}

void myHandler(const char *event, const char *data) {
    if (!data) return;
    val = atoi(data); 
    Serial.println(val); 
    compare(); 
}

void loop() {
  callTime(); 
  compTime();
  compare(); 
 
}

Credits

fiona
1 project • 0 followers

Comments