Lab 5: Paired Devices with Webhooks

Made by Wendy Rodriguez, Weiqing Wang and Nicole Korber

Pair different argons

Created: December 13th, 2022

0

Outcome

    • Connect multiple argon devices. The major function is that one can let the other's neopixel turn into red when he/she wants to convey information through this color changing. 

0

Process

The purpose of this lab was to connect multiple argons with the help of Webhooks. The main issue the team encountered during this lab was with Webhooks. In the portion of the device ID, one team member placed their device ID instead of another teammate's ID. Once this error was discovered, both argons ran the code perfectly. This concept of connecting argons can be very beneficial for our team's GlowCap project to connect our cap with our hub.

0

Reflection


Our team learned a different way to connect multiple argon devices. The team has used the Blynk IoT platform to flash or message code to another device, specifically Arduino. Compared to Blynk, Webhooks is much easier was much easier to use and will result in the team using it for the connection of multiple devices. 

0
// 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>

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

// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_PIN D2
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
// Our button wired to D0
int switchPin = D3;
int brightness = 0;
int increment = 255;
int takePeriod = 3 * 1000;
// store the color changing state
bool change = false;


void setup(){

pinMode( switchPin , INPUT_PULLUP); // sets pin as input

strip.begin();

Particle.subscribe( "changeColor", handleColorChanging );
}

// store the brightness in a new variable

void loop(){
    int switchState = digitalRead( switchPin );
	if( switchState == LOW ){
        delay(takePeriod);
        uint32_t c = strip.Color(255,255,0); // yellow
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, c); // set a color 
            }
        strip.show();
        if( change == true ){
            Particle.publish( "doPairedPublish" );
            delay(3000);
            changeColor();
        }
	}else{
	    uint32_t c = strip.Color(255,255,255); // white
        for( int i = 0; i < strip.numPixels(); i++ ){
            strip.setPixelColor(i, c); // set a color 
            }
        strip.show();
        change = false;
	}
}

void changeColor(){    //function to fade an LED

    uint32_t c = strip.Color(255,0,0); // red
    for( int i = 0; i < strip.numPixels(); i++ ){
        strip.setPixelColor(i, c); // set a color 
        }
    strip.show();

}

void handleColorChanging( const char *event, const char *data){
   change = true;
}
Click to Expand
0
Lab 5: Paired Devices with Webhooks
Weiqing Wang - https://youtu.be/ULq3u7jyC8I
x