Ivan Ramos
Published

Lane Tech HS - PCL - Data Visualization

YouTube HAPPYMETER -A small device that uses two different APIs to rate the positivity/negativity of a Youtube video and show it on a meter.

BeginnerFull instructions provided40
Lane Tech HS - PCL - Data Visualization

Things used in this project

Hardware components

Argon
Particle Argon
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1

Hand tools and fabrication machines

Scissors, Free Fall
Scissors, Free Fall

Story

Read more

Schematics

HappyMeter Schematics

Code

Full HappyMeter Code

C/C++
Fill in Video ID for the string defined on line 2.
Make sure you get the right pin on line 15
Subscribe to your two webhooks on lines 12 and 13, you don't need to name them the same way I did, but be sure they are the right ones.
String VIDEOID = "VIDEOID";
String TOPCOMMENT;

Servo myservo;
int pos = 90;  

void setup()
{
    //Subscribe to the webhook response event
    Particle.subscribe("hook-response/youtube comments", commentHandler, MY_DEVICES);
    Particle.subscribe("hook-response/vibe check", vibeHandler, MY_DEVICES);
    Serial.begin(9600);
    myservo.attach(D3);  // attaches the servo on the D3 pin to the servo object
    myservo.write(90);
    Particle.publish("youtube comments", VIDEOID, PUBLIC);
}

void commentHandler(const char *event, String data)
{

    TOPCOMMENT = String(data);
    delay(1000);
    Particle.publish("vibe check", TOPCOMMENT, PRIVATE);

}

void vibeHandler(const char *event, const char *data)
{
    
    float score = atof(data);
    
    pos = 90 - score*280;
    if (pos > 180)
    {
        pos = 180;
    }
    if (pos < 0)
    {
        pos = 0;
    }
    myservo.write(pos);
    
}

Credits

Ivan Ramos

Ivan Ramos

2 projects • 1 follower
Thanks to twinword and ytdlfree.

Comments

Add projectSign up / Login