Last active
December 17, 2015 01:29
-
-
Save llad/5529050 to your computer and use it in GitHub Desktop.
First Beaglebone code using Bonescript. Makes the on-board LEDs cycle.
This file contains hidden or 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
var b = require('bonescript'); | |
// Initialize variables | |
var startLED = 0, | |
delay = 100, | |
status = b.LOW; | |
// Set all the onboard LEDs for OUTPUT | |
b.pinMode("USR0", b.OUTPUT); | |
b.pinMode("USR1", b.OUTPUT); | |
b.pinMode("USR2", b.OUTPUT); | |
b.pinMode("USR3", b.OUTPUT); | |
// Set all LEDs to low | |
b.digitalWrite('USR0', b.LOW); | |
b.digitalWrite('USR1', b.LOW); | |
b.digitalWrite('USR2', b.LOW); | |
b.digitalWrite('USR3', b.LOW); | |
// interval call for loop | |
setInterval(jump, delay); | |
// loop function | |
function jump() { | |
//set LED pin string | |
pin = "USR" + startLED; | |
// turn LED on if off | |
if (status == b.LOW) { | |
pin = "USR" + startLED; | |
status = b.HIGH; | |
b.digitalWrite(pin, status); | |
} | |
// turn LED off if on and move to the next LED pin | |
else { | |
status = b.LOW; | |
b.digitalWrite(pin, status); | |
startLED++; | |
if (startLED == 4) startLED =0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can remove extra
pin = "USR" + startLED;