Aaron Hall
Published

PCLSculpt Gun Violence

A visualization of the Gun Violence data of the city of Chicago.

IntermediateFull instructions provided54
PCLSculpt Gun Violence

Things used in this project

Hardware components

Photon 2
Particle Photon 2
×1
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
Adafruit NeoPixel Digital RGB LED Strip 144 LED, 1m White
Two strips of one LED each connected in series.
×1
Stepper Motor
Digilent Stepper Motor
×1
External Power supply
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Generic solid core wire
×1
Generic Stranded Wire
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Hand tools and fabrication machines

Tape, Clear
Tape, Clear
Hot glue gun (generic)
Hot glue gun (generic)
Solder Flux, Soldering
Solder Flux, Soldering
Scissor, Electrician
Scissor, Electrician
Cardboard
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
Soldering iron (generic)
Soldering iron (generic)
Wood
Warbla clay
construction paper
Barbie arm
3D Printer (generic)
3D Printer (generic)
3D printer filament

Story

Read more

Code

PCLSculpt

C/C++
This code pulls data from Chicago Data Portal and triggers a motor and LEDs every 24 hours.
#include <Stepper.h>
#include <neopixel.h>
#include "Particle.h"


SYSTEM_MODE(AUTOMATIC);

#if (PLATFORM_ID == 32)
// MOSI pin MO
#define PIXEL_PIN SPI1
// MOSI pin D2
// #define PIXEL_PIN SPI1
#else // #if (PLATFORM_ID == 32)
#define PIXEL_PIN D2
#endif
#define PIXEL_COUNT 3
#define PIXEL_TYPE WS2812B


int stepsPerRev = 409.6;

int IN1 = D1;
int IN2 = D5;
int IN3 = D3;
int IN4 = D4;

int btnState;

int left = 0;
int right = 0;


String first = "";
String second = "";
String third = "";

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

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

int button = 6;

SerialLogHandler logHandler(LOG_LEVEL_INFO);

const unsigned long DAY = 86400 * 1000;
unsigned long lastCall = 0;

void setup() {
  pinMode(button, INPUT_PULLUP);
  
  strip.begin();
  strip.show();
  
  Particle.subscribe("hook-response/ChicagoInfo", handleEventResponse, MY_DEVICES);
  Particle.publish("ChicagoInfo");
  
  myStepper.setSpeed(17);
  Serial.begin(9600);
  
}

void loop() {
    if (millis() > lastCall + DAY) {
        lastCall = millis();
        Particle.publish("ChicagoInfo");
    }
}

void handleEventResponse(const char *event, const char *data){
    String response = String(data);
    
    char stringBuffer[256] = "";
    response.toCharArray(stringBuffer, 256);
    
    first = strtok(stringBuffer, "_");
    first = first.substring(0, 10);
    // first = "0";
    second = strtok(NULL, "_");
    second = second.substring(0, 10);
    third = strtok(NULL, "_");
    third = third.substring(0, 10);
    
    Serial.println("data received");
    Serial.println(first);
    Serial.println(second);
    Serial.println(third);
    
    if (first == second && second == third){
        for(int i = 0; i < 3; i++){
            strip.setColor(i, 255, 0, 0);
        }
        strip.show();
        if(left < 4){
            Serial.println("clockwise");
            myStepper.step(-stepsPerRev);
            left ++;
            right --;
        }
    } else {
        for(int i = 0; i < 3; i++){
            strip.setColor(i, 0, 0, 255);
        }
        strip.show();
        if(right < 4){
            Serial.println("counterclockwise");
            myStepper.step(stepsPerRev);
            right++;
            left--;
        }
    }
    delay(500);
    for(int i = 0; i < 3; i++){
        strip.setColor(i, 0, 0, 0);
    }
    strip.show();
}

Credits

Aaron Hall
1 project • 0 followers
Thanks to Nayema C.

Comments