Popup Box
Made by Maya Pandurangan, lortega and mspettel
Made by Maya Pandurangan, lortega and mspettel
We sought out to create a way to communicate with those you have a competitive relationship with, over long distances.
Created: October 11th, 2019
We sought out to create a way to communicate with those you have a competitive relationship with, over long distances.
A little friendly competition never hurt anyone. Our solution is to have two buttons. The goal is to keep the button in the off position where it is pushed down. When a person presses their button down, the other person’s button pops up. The other person has to push it down and return their button to the off position as soon as possible. This lets users (friends, uber-competitive siblings, arch nemeses, etc…) stay in touch in a fun way that keeps their competitive sides alive.
We created an IoT device that consists of two identical buttons, button A and button B. Each button is equipped with a push sensor, solenoid, and LED. When button A is pushed, the solenoid is pulled down (which keeps the button low), the LED is turned off, and a message is published to the mesh network. Button B is subscribed to listen to button A, so when it receives a message, button B pops up with the solenoid and turns its LED on. Button A can also listen for when B is pressed.
While building the Popup Box, we ran into a few challenges.
We tried using an arcade button to detect when the button was pressed, but it was hard to get the button to press down on the correct part of the arcade button with the solenoid in the way. We ended up switching to a push button because it was more sensitive to pressure and was smaller.
At first, our solenoids were going up and down very weakly. After troubleshooting, we realized this was because we 9V was not enough power. We swapped these out for 12V batteries and used those instead.
//For button one
/ This #include statement was automatically added by the Particle IDE.
#include "lib1.h"
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
//PopupBox
/*
subscribed to listen to button presses
when button pressed, led and solenoid turn off, for other button, led and solenoid turn on
*/
#define PIXEL_PIN D6
#define PIXEL_COUNT 24
#define PIXEL_TYPE WS2812B
int solOne = D12;
int button = D3;
int buttonOneState = 0;
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
Particle.subscribe("buttonOne", myHandler);
pinMode(solOne, OUTPUT);
pinMode(button, INPUT);
turnOff();
strip.begin();
strip.show();
}
void loop() {
buttonOneState = digitalRead(button);
//publish buttonState as solone t or f
if (buttonOneState == HIGH){
Particle.publish("buttonTwo","pressed",PUBLIC);
digitalWrite(solOne, HIGH);
turnOff();
}
else{
}
delay(100);
}
// Now for the myHandler function, which is called when the cloud tells us that our buddy's event is published.
void myHandler(const char *event, const char *data)
{
if (strcmp(data,"pressed")==0) {
digitalWrite(solOne, LOW);
turnOn();
}
else {
// if the data is something else, don't do anything.
// Really the data shouldn't be anything but those two listed above.
}
}
void turnOn()
{
for(uint16_t i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(255, 255, 0));
}
strip.show();
}
void turnOff()
{
for(uint16_t i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 0, 0);
}
strip.show();
}
Click to Expand
//For button two
// This #include statement was automatically added by the Particle IDE.
#include "lib1.h"
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
//PopupBox
/*
subscribed to listen to button presses
when button pressed, led and solenoid turn off, for other button, led and solenoid turn on
*/
#define PIXEL_PIN D6
#define PIXEL_COUNT 16
#define PIXEL_TYPE WS2812B
int solOne = D12;
int button = D3;
int buttonOneState = 0;
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
void setup() {
Particle.subscribe("buttonTwo", myHandler);
pinMode(solOne, OUTPUT);
pinMode(button, INPUT);
turnOn();
strip.begin();
strip.show();
}
void loop() {
buttonOneState = digitalRead(button);
//publish buttonState as solone t or f
if (buttonOneState == HIGH){
Particle.publish("buttonOne","pressed",PUBLIC);
digitalWrite(solOne, HIGH);
turnOff();
}
else{
}
delay(100);
}
// Now for the myHandler function, which is called when the cloud tells us that our buddy's event is published.
void myHandler(const char *event, const char *data)
{
if (strcmp(data,"pressed")==0) {
digitalWrite(solOne, LOW);
turnOn();
}
else {
// if the data is something else, don't do anything.
// Really the data shouldn't be anything but those two listed above.
}
}
void turnOn()
{
for(uint16_t i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(255, 255, 0));
}
strip.show();
}
void turnOff()
{
for(uint16_t i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, 0, 0, 0);
}
strip.show();
}
Click to Expand
Thermostats, locks, power sockets, and lights are all being imbued with smarts making them increasingly aware and responsive to their environment and users. This course will chart the emergence of ...more
We sought out to create a way to communicate with those you have a competitive relationship with, over long distances.