Created
October 1, 2017 18:20
-
-
Save bennycode/e02c354e5e2ac7a4333c01f006a423a1 to your computer and use it in GitHub Desktop.
Blinking LEDs example (BeagleBone Black Wireless)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
'use strict'; | |
const b = require('bonescript'); | |
console.log('VERSION', 2); | |
console.log(`Working directory of the Node.js process: ${process.cwd()}`); | |
const leds = ['USR0', 'USR1', 'USR2', 'USR3', 'P9_14']; | |
// Prepare LEDs | |
for (const led of leds) { | |
b.pinMode(led, b.OUTPUT); | |
} | |
function lightOn(turnOn) { | |
const state = (turnOn) ? b.HIGH : b.LOW; | |
for (const led of leds) { | |
b.digitalWrite(led, state); | |
} | |
} | |
function toggleLEDs() { | |
let turnOn = false; | |
setInterval(() => { | |
lightOn(turnOn); | |
turnOn ^= true; | |
}, 1000); | |
} | |
toggleLEDs(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment