Fork me on GitHub
beagleboard.org

BoneScript

You might be able to see a newer version of this on beagleboard.org/support/bonescript/demo_blinkled_external

Demo: Blink an external LED

Code

var b = require('bonescript');
var led = "P8_13";
var state = 0;

b.pinMode(led, 'out');
toggleLED = function() {
 state = state ? 0 : 1;
 b.digitalWrite(led, state);
};

timer = setInterval(toggleLED, 100);

stopTimer = function() {
 clearInterval(timer);
};

setTimeout(stopTimer, 30000);

Build and execute instructions

  • Connect an LED and resistor as shown being sure to get the anode/cathode orientation correct.
  • Run the example code and observe the blinking.
  • Alter the frequency and re-run the example.

See also

Topics

Related functions

Examples