Home

Up: Smart Plug

Previous: Smart Plug Intro

Smart Plug Prototype 0.1

After busting out the old Beaglebone Black and writing a few lines of JavaScript, I have a super simple LED toggle sequence on a timer running.

All it does is run a timer that switches the LEDs on and off at a fixed rate. Obviously nowhere near useful, but this is a simple building block. Next up we need to be able to control it.

var b = require('bonescript');
var net = require('net');
var LEDS = [
  'USR0',
  'USR1',
  'USR2',
  'USR3'
];
LEDS.forEach(function (LED) {
  b.pinMode(LED, b.OUTPUT);
});
var on_led_index = 0;
setInterval(function () {
  b.digitalWrite(LEDS[on_led_index], b.LOW);
  on_led_index = (on_led_index + 1) % 4;
  b.digitalWrite(LEDS[on_led_index], b.HIGH);
}, 1000);

Next: Smart Plug Prototype 0.2

Creative Commons License