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:
LinkedinTwitter

Leave a Comment

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

Scroll to Top