Skills Dev V: Working with Networking (Team Project)

Made by Justin Slusher, Nik Kim and Stephanie Ho

Testing interactions and sending/ receiving data using particle publish and subscribe.

Created: December 5th, 2023

0

Project Team:

Stephanie Ho

Nik Kim

Justin Slusher

_____________

Project Summary:  This project covers how to make connections with another device and trigger others' devices to operate.

Process: When the user inputs 'setTime' in the particle dashboard and hits the button, the paired user's motor sweeps once. We tested using each other's access codes to complete the motion (Nik -> Stephanie -> Justin -> Nik). 

Outcome:  Connected device of three team members, using particle publish and subscribe.

0
// Skill Dev #5: Working with Networking

// Servo
Servo servo;
int servoPin = A3;

// Switch button
int pushBtn = D3;

int minutes = 0;

void setup() {
    Serial.begin(9600);

    // Setup servo
    servo.attach(servoPin);
    servo.write(0);
    delay(500);
    servo.write(180);
    delay(500);

    pinMode(pushBtn, INPUT_PULLUP);

    Particle.function("setTime", setTime);
    
    Particle.subscribe("blinkLED", handleRemoteEvent);
}

void loop() {

    int switchState = digitalRead(pushBtn);

    if (switchState == LOW) {
   
        Particle.publish("doPairedPublish");
    }
}

int setTime(String cmd) {
    minutes = cmd.toInt();
    return minutes;
}

void handleRemoteEvent(const char *event, const char *data) {
   
    int position = String(data).toInt();
    servo.write(position);
}
Click to Expand
0
0

Next Steps: Each time we tested the paired function, we had to re-flash the code in order to test again. In a future iteration, it would be useful to add a "reset" code to the system that can reset after performing the function.  

Reflection: Making a connection was more difficult than what we expected. We started testing from complex code, but eventually needed to clean up our code to understand how things work.

x
Share this Project

Courses

48-675 Designing for the Internet of Things 24

· 11 members

A hands-on introductory course exploring the Internet of Things and connected product experiences.


About

Testing interactions and sending/ receiving data using particle publish and subscribe.