Driving a LED array from a BeagleBone Black

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); } }

Driving a LED array from a BeagleBone BlackThis 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

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top