Margaret Donohoe
Published © GPL3+

Lane Tech HS - PCL - COVID-19 "High Striker"

This project represents the City of Chicago's data on current Coronavirus death rates with a "replica" of the popular hammer carnival game.

IntermediateShowcase (no instructions)146
Lane Tech HS - PCL - COVID-19 "High Striker"

Things used in this project

Hardware components

Argon
Particle Argon
×1
Breadboard (generic)
Breadboard (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Software apps and online services

Particle Build Web IDE
Particle Build Web IDE

Story

Read more

Schematics

Schematics

Code

Code

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

Servo myservo;
int servoPos = 0;

StaticJsonDocument<48> doc;

void setup()
{
    Particle.subscribe("hook-response/totalchicagodeaths", myHandler, MY_DEVICES);
    myservo.attach(D8);
    Serial.begin(9600);
}

void loop()
{
  String data = String(10);
  Particle.publish("caserate", data, PRIVATE);
  double newTotal;
  char *eptr;
  newTotal = strtod(data, &eptr);
  
  if(newTotal > 0)
  {
    int maxPos = newTotal * 3.6;
    for(servoPos = 0; servoPos <= maxPos; servoPos++)
    {
        myservo.write(servoPos);
        delay(30);
    }
    for(servoPos = maxPos; servoPos >= 0; servoPos--)
    {
        myservo.write(servoPos);
        delay(30);
    }
  }
  
  delay(5000);
}

void myHandler(const char *event, const char *data)
{
    const char* json = data;

    deserializeJson(doc, json);

    float total = atof(data);
    
    Serial.println(total);
}

Credits

Margaret Donohoe

Margaret Donohoe

3 projects • 1 follower

Comments

Add projectSign up / Login