I've done a lot of projects over the holidays. This is a quick collection of notes to remind myself later.
I took the insides out of an old IKEA Spøka nightlight and squeezed in a Particle Photon, a battery shield and a battery then soldered the nightlight's on/off switch onto some jumper cables and wired that in. I now have an internet-connected button that looks cute.
Still no idea what to do with it but it’s fun.
Here's the code that's running on the Photon:
int led = D7; // Built-in LED
int pushButton = D6; // Old Spøka momentary switch
bool wasUp = true;
void setup() { pinMode(led, OUTPUT); pinMode(pushButton, INPUT_PULLUP); }
void loop() { int pushButtonState;
pushButtonState = digitalRead(pushButton);
if(pushButtonState == LOW) { // If we push down on the push button digitalWrite(led, HIGH); // Turn ON the LED if(wasUp) { Particle.publish("Spooky pressed"); wasUp = false; } } else { digitalWrite(led, LOW); // Turn OFF the LED wasUp = true; }
}
When you press the button, you get a message published to the Particle Cloud.