For the Dutch Sinterklaas surprise (like secret Santa or invisible friend), I had to create something new.
I found https://github.com/esp8266/Arduino a while ago and decided this was a perfect opportunity to work with it.
This project lights 8 led’s red upon booting, spawns an WiFi access-point and hosts a website.
The website has a list of 8 questions and every correct answer changes a red led to a green one.
When all led’s are green, the game is over.
All the code can be found on my github: https://github.com/timdows/AMD/tree/master/Sinterklaas surprise ESP8266
The setup method sets the GPIO pins to output, starts the WiFi access-point, holds three entry points for webpages (/, /vragen, /reset) and tracks some headers via server.collectHeaders(headerkeys, headerkeyssize);
The loop method makes sure that the ESP8266WebServer object is updated.
setPixelCorrect(i) sets the representing led’s index on the ledstrip to green.
ledstripOff sets all the leds off.
ledstripToStart sets all the leds red.
The vragen method checks for cookies and validates the input value, if it matches the led is made green.
I have tried to create a post-redirect-get pattern to make sure that refreshing the page didn’t re-post the previous answers.
|8 led pixel strip||$ 1.97|
|2200 mAh power bank||$ 4|
|Other materials||$ 0.5|
- Have some more inspiration for the questions.