Sticking with βBoneScriptβ in the Cloud 9 IDE, I began by copying the single LED code and generalising it to also flash the next seven pins. I worked out From the same diagram where I found the name βP8_12β, that the next few pins on that side of the connector were βP8_14β, βP8_16β and so on.:
var b = require(βbonescript'); var state = b.LOW; var leds = [ βP8_12β, βP8_14β, βP8_16β, βP8_18β, βP8_20β, βP8_22β, βP8_24β, βP8_26β ]; for (var i = 0; i < leds.length; ++i) { b.pinMode(leds[i], b.OUTPUT); } setInterval(toggle, 1000); function toggle() { if(state == b.LOW) state = b.HIGH; else state = b.LOW; for (var i = 0; i < leds.length; ++i) { b.digitalWrite(leds[i], state); } }
This kind of worked. Pins βP8_12β, βP8_14β, βP8_16β, βP8_18β and βP8_26β flashed happily, but βP8_20β, βP8_22β and βP8_24β seemed to be being used by something else, as they stayed mostly dark, flickering occasionally.
I was partly expecting this, though. One of the things about the BeagleBone Black is that even though it has lots and lots of pins, it has even more things it could do with them, so most of the pins have multiple possible uses. In BeagleBone terms these are known as βmuxesβ. In general, mux 7 is GPIO, so I made a slight modification to the initialisation code to set the pins into mode 7:
for (var i = 0; i < leds.length; ++i) { b.pinMode(leds[i], b.OUTPUT, 7); }
Unfortunately, this had no effect at all. It seems that the setting of the mux, although supported in the BoneScript API, is not actually implemented yet. At this point, I had two choices β look for some other pins which already work as GPIO pins without setting the mux, or work out how to change the mux outside BoneScript. A qiick google turned up several people asking how to do it, but no obvious answers. So I took the lazy approach and tried some different pins until I found eight which all worked.
For mroe detail: Driving a LED array from a BeagleBone Black