Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Monsters, mailboxes and other nonsense @ Front-...

Monsters, mailboxes and other nonsense @ Front-Trends

The Internet of Things can become quite boring pretty fast. Turning on the lights in your apartment with an app is a nice novelty, but it isn’t really very creative. And as developers we like to tinker and look under the hood, but manufacturers like their walled gardens. This talk is about combining sensors, switches and displays with different technologies to solve problems that don’t really exist and more importantly just to have fun with IoT and make geeky stuff. This talk contains monsters, and lots of them.

Niels Leenheer

May 24, 2017
Tweet

More Decks by Niels Leenheer

Other Decks in Technology

Transcript

  1. #include <Adafruit_NeoPixel.h> #define PIN D1 #define PIXELS 24 Adafruit_NeoPixel strip

    = Adafruit_NeoPixel(PIXELS, PIN, NEO_GRB + NEO_KHZ800); void setup(void) { strip.begin(); strip.setBrightness(255); strip.setPixelColor(0, strip.Color(0, 0, 255)); strip.show(); } void loop(void) { }
  2. int i = 0; void setup(void) { strip.begin(); strip.setBrightness(255); }

    void loop(void) { i = (i + 1) % PIXELS; strip.setPixelColor(i % PIXELS, strip.Color(0, 0, 0)); strip.setPixelColor((i + 1) % PIXELS, strip.Color(0, 0, 63)); strip.setPixelColor((i + 2) % PIXELS, strip.Color(0, 0, 127)); strip.setPixelColor((i + 3) % PIXELS, strip.Color(0, 0, 195)); strip.setPixelColor((i + 4) % PIXELS, strip.Color(0, 0, 255)); strip.show(); delay(8); }
  3. const char* ssid = "........"; const char* password = "........";

    ESP8266WebServer server(80); void setup(void) { WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) delay(500); server.on("/on", [](){ server.send(200, "text/plain", "on"); }); server.on("/off", [](){ server.send(200, "text/plain", "off"); }); server.begin(); } void loop(void) { server.handleClient(); }
  4. editor.addEventListener('touchstart', handleTouch); editor.addEventListener('touchmove', handleTouch); function handleTouch(e) { for (var i

    = 0; i < e.changedTouches.length; i++) { let elem = document.elementFromPoint( e.changedTouches[i].pageX, e.changedTouches[i].pageY ); if (elem.tagName && elem.tagName == 'TD' && 
 editor.contains(elem)) 
 { drawPixel(elem); } } e.preventDefault(); }
  5. editor.addEventListener('touchstart', handleTouch); editor.addEventListener('touchmove', handleTouch); function handleTouch(e) { for (var i

    = 0; i < e.changedTouches.length; i++) { let elem = document.elementFromPoint( e.changedTouches[i].pageX, e.changedTouches[i].pageY ); if (elem.tagName && elem.tagName == 'TD' && 
 editor.contains(elem)) 
 { drawPixel(elem); } } e.preventDefault(); }
  6. let socket = new WebSocket( "ws://" + window.location.host + "/ws"

    ); function drawPixel(elem) { if (elem.dataset.color != currentColor) { elem.dataset.color = currentColor; elem.style.backgroundColor = '#' + currentColor; socket.send(JSON.stringify({ command: "draw", x: elem.dataset.x, y: elem.dataset.y, color: currentColor })); } }
  7. let socket = new WebSocket( "ws://" + window.location.host + "/ws"

    ); function drawPixel(elem) { if (elem.dataset.color != currentColor) { elem.dataset.color = currentColor; elem.style.backgroundColor = '#' + currentColor; socket.send(JSON.stringify({ command: "draw", x: elem.dataset.x, y: elem.dataset.y, color: currentColor })); } }
  8. socket.onmessage = function(msg) { let data = JSON.parse(msg.data); if (data.command

    == "draw") { let elem = document.querySelector( 'td[data-x=' + data.x + ']' + 
 '[data-y=' + data.y + ']' ); elem.dataset.color = data.color; elem.style.backgroundColor = '#' + data.color }; } }
  9. socket.onmessage = function(msg) { let data = JSON.parse(msg.data); if (data.command

    == "draw") { let elem = document.querySelector( 'td[data-x=' + data.x + ']' + 
 '[data-y=' + data.y + ']' ); elem.dataset.color = data.color; elem.style.backgroundColor = '#' + data.color }; } }