We have collected enough information to program an onboard LED. BeagleBone comes with four small onboard user LEDs. They are located above the mini USB port. They are labeled as USER LEDs and named USER0, USER1, USER2, and USER3 LEDs. You can refer to the following image. We will turn on USER3 LED, which is configured by default to turn on each time the emmc is accessed:
Create a new file in Cloud9 as we did in the previous chapter. Write the following code in it and save it as turnOnUSER3.js
. Run the program and you should see USER3 LED turned on. The code for turnOnUSER3.js
is as follows:
var b = require('bonescript'); b.pinMode("USR3", b.OUTPUT); b.digitalWrite("USR3", b.HIGH);
Now, turning the USER3 LED off is straightforward. You just need to change b.HIGH
to b.LOW
in the digitalWrite()
function. Save the code as turnOffUSER3.js
. Run the program and you should see the USER3 LED turned off. The code for turnOffUSER3.js
is as follows:
var b = require...