Skip to content

Instantly share code, notes, and snippets.

@blindman2k
Created May 9, 2014 21:44
Show Gist options
  • Save blindman2k/69e175af53b3e6dcad56 to your computer and use it in GitHub Desktop.
Save blindman2k/69e175af53b3e6dcad56 to your computer and use it in GitHub Desktop.
Uses an impeeduino to test the imp.scanwifinetworks() while in offline mode.
// Pin 2 is the red LED
ACTIVITY <- hardware.pin2;
ACTIVITY.configure(DIGITAL_OUT);
ACTIVITY.write(1);
// Pin 8 is the orange LED
LINK <- hardware.pin8;
LINK.configure(DIGITAL_OUT);
LINK.write(1);
function blink_link(count = 5, led = LINK, speed = 0.3) {
for (local i = 0; i < count; i++) {
led.write(0);
imp.sleep(speed);
led.write(1);
imp.sleep(speed);
}
}
function scan_and_send() {
ACTIVITY.write(0);
local nets = imp.scanwifinetworks();
ACTIVITY.write(1);
if (nets) blink_link(nets.len())
}
function loop() {
imp.wakeup(10, loop);
blink_link(10, ACTIVITY, 0.05);
scan_and_send();
}
loop();
imp.wakeup(10, function() {
server.disconnect();
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment