Skills Dev V: Working with Networking

Made by Grace Zhu, Yulin Chen and Narayan Ashanahalli

Practice developing paired devices and networked interactions with Particle.publish

Created: December 4th, 2024

0

Intention

In this project I worked with my team to re-make Kiss Communicator.

0

Context

The Kiss Communicator connects people across distances. Users blow into it to send a "kiss" as animated light patterns. The recipient’s device signals the message, which plays once when squeezed, making each "kiss" a fleeting, meaningful gesture.

In this small prototype, we simulated the breath to light conversion and send light signals to a different device.

0

Process

  1. Testing with wind sensor
  2. Adding wind sensor input and light sequence output via neopixel
  3. Testing publish/subscribe events with an LED on a single device
  4. Testing publish/subscribe events with webhook between two devices
  5. Separate input and output to two devices using webhook
0

Outcome

    • We successfully created a prototype that translates breathe data to light sequences. Currently it's one direction including a publisher and subscriber.

0

Reflection

  1. Using different light states as user feedback to indicate different actions

  2. Sending data between different devices with webhooks

0
Kiss Communicator Prototype
Grace Z - https://youtu.be/TSckeIfOaZI
0
// This #include statement was automatically added by the Particle IDE.

#include "Particle.h"
#include <neopixel.h>

#define PIXEL_PIN SPI
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
uint16_t i;
uint32_t c = strip.Color(0, 0, 0);
int buttonPin = D2;
unsigned long lastFade = 0;
int Interval = 3000;

bool receive_or_not = false;
bool signall = true;
int breathecountreceive = 0;
int buttonState = digitalRead( buttonPin );

void setup(){
    strip.begin();
    strip.show();
    Particle.subscribe("kissReceive", handlekiss);
    Serial.begin( 9600 );
}

void handlekiss(const char *event, const char *data) {
    breathecountreceive = atoi(data);
    receive_or_not = true;
    signall = true;
}

void loop(){
    Serial.println(breathecountreceive);
    Serial.println(receive_or_not);
    Serial.println(buttonState);
    buttonState = digitalRead( buttonPin );
    // int breathecountreceive1 = atoi(data);
    // if(breathecountreceive1!=breathecountreceive){
    //     receive_or_not = true;
    // }
    
    if(receive_or_not == true){
        if (signall == true){
            for(int i = 0 ;i < breathecountreceive ;i++){
                unsigned long now = millis();
                Secondstagebreathe1();
                lastFade = now;
            }
            // for( i = 0;i<3;i++){
            //     Receivepinksignal();
            // }
        }
        signall = false;
        // else if (buttonState==LOW){
        //     for(i=0;i<breathecountreceive;i++){
        //         Secondstagebreathe();
        //     }
        //     signall = false; 
        // }
    }
    delay(500);
    // receive_or_not = false;
    
}

void Receivepinksignal(){
    for(i=0; i< strip.numPixels(); i++) {
        c = strip.Color(0, 0, 255);
        strip.setPixelColor(i, c );
		strip.show();
		delay( 5 );
    }
    for(i=0; i< strip.numPixels(); i++) {
        c = strip.Color(0, 0, 0);
        strip.setPixelColor(i, c );
		strip.show();
		delay( 5 );
    }
}

void Secondstagebreathe(){
    c = strip.Color(255, 255, 255);
    unsigned long now = millis();
    c = strip.Color(0, 0, 0);
    if ((now - lastFade) >= Interval) {
        for (int color = 0; color < 255; color++) {
            for (i = 0; i < strip.numPixels(); i++) {
                c = strip.Color(color, color, color);
                strip.setPixelColor(i, c);
            }
            strip.show();
            delay(5);
        }
                
        for (int color = 255; color > 0; color--) {
            for (i = 0; i < strip.numPixels(); i++) {
                c = strip.Color(color, color, color);
                strip.setPixelColor(i, c);
            }
            strip.show();
            delay(5);
        }
    lastFade = now;
    }
}

void Secondstagebreathe1(){

    for (int color = 0; color < 255; color++) {
        for (i = 0; i < strip.numPixels(); i++) {
            c = strip.Color(color, color, color);
            strip.setPixelColor(i, c);
        }
        strip.show();
        delay(5);
    }
                
    for (int color = 255; color > 0; color--) {
        for (i = 0; i < strip.numPixels(); i++) {
            c = strip.Color(color, color, color);
            strip.setPixelColor(i, c);
        }
        strip.show();
        delay(5);
    }


}
Click to Expand
0
// This #include statement was automatically added by the Particle IDE.

#include "Particle.h"
#include <neopixel.h>

#define PIXEL_PIN SPI
#define PIXEL_COUNT 8
#define PIXEL_TYPE WS2812

Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
uint16_t i;
uint32_t c = strip.Color(0, 0, 0);
int buttonPin = D2;
unsigned long lastFade = 0;
int Interval = 3000;

bool receive_or_not = false;
bool signall = true;
int breathecountreceive = 0;
int buttonState = digitalRead( buttonPin );

void setup(){
    strip.begin();
    strip.show();
    Particle.subscribe("kissReceive", handlekiss);
    Serial.begin( 9600 );
}

void handlekiss(const char *event, const char *data) {
    breathecountreceive = atoi(data);
    receive_or_not = true;
}

void loop(){
    Serial.println(breathecountreceive);
    Serial.println(receive_or_not);
    Serial.println(buttonState);
    buttonState = digitalRead( buttonPin );
    
    if(receive_or_not == true){
        if (signall == true){
            for(int i = 0 ;i < breathecountreceive ;i++){
                unsigned long now = millis();
                
                Secondstagebreathe1();
                
                lastFade = now;
            }
            // for( i = 0;i<3;i++){
            //     Receivepinksignal();
            // }
        }
        signall = false;
        // else if (buttonState==LOW){
        //     for(i=0;i<breathecountreceive;i++){
        //         Secondstagebreathe();
        //     }
        //     signall = false; 
        // }
    }
    delay(500);
    
}

void Receivepinksignal(){
    for(i=0; i< strip.numPixels(); i++) {
        c = strip.Color(0, 0, 255);
        strip.setPixelColor(i, c );
		strip.show();
		delay( 5 );
    }
    for(i=0; i< strip.numPixels(); i++) {
        c = strip.Color(0, 0, 0);
        strip.setPixelColor(i, c );
		strip.show();
		delay( 5 );
    }
}

void Secondstagebreathe(){
    c = strip.Color(255, 255, 255);
    unsigned long now = millis();
    c = strip.Color(0, 0, 0);
    if ((now - lastFade) >= Interval) {
        for (int color = 0; color < 255; color++) {
            for (i = 0; i < strip.numPixels(); i++) {
                c = strip.Color(color, color, color);
                strip.setPixelColor(i, c);
            }
            strip.show();
            delay(5);
        }
                
        for (int color = 255; color > 0; color--) {
            for (i = 0; i < strip.numPixels(); i++) {
                c = strip.Color(color, color, color);
                strip.setPixelColor(i, c);
            }
            strip.show();
            delay(5);
        }
    lastFade = now;
    }
}

void Secondstagebreathe1(){

    for (int color = 0; color < 255; color++) {
        for (i = 0; i < strip.numPixels(); i++) {
            c = strip.Color(color, color, color);
            strip.setPixelColor(i, c);
        }
        strip.show();
        delay(5);
    }
                
    for (int color = 255; color > 0; color--) {
        for (i = 0; i < strip.numPixels(); i++) {
            c = strip.Color(color, color, color);
            strip.setPixelColor(i, c);
        }
        strip.show();
        delay(5);
    }


}
Click to Expand
x
Share this Project


About

Practice developing paired devices and networked interactions with Particle.publish