You are reading a single comment by @Robet and its replies. Click here to read the full conversation.
  • Hey guys,

    basically im a young electronics engineer who has a passion for arty farty things and this is a project ive been brewing for sometime.

    The actual end product is probaby best described as this; Its an A3 sized sheet of clear/slightly misted plastic that has a grid of RGB LED's laid behind it, which are controlled by the Espruino.

    I then produce black and white artwork onto sheets of clear acetate (causing it be black and clear artwork). This artwork is then overlaid/pinned to the item described previously. What this hopes to achieve is that it provides me with a piece of black and white artwork (sorta comic style) in which I am able to control the flow of colour within the 'white or clear' areas.

    Think like what doctors pin their x-rays to, except it looks like your bones are taking a funky acid trip :)

    Currently not having any issues with the physical build, but I am having issues with the coding and general understanding of the control of the LEDs. I have little coding experience, i get what a unit array is and a for loop, and the need to define, then call a function etc.. but nothing beyond very basic work.

    I was hoping someone could help me dissect the code from the RGB LED tutorial on here (this is the tutorial:­ressable+LEDs)

    var rgb = new Uint8Array(25*3);
    function getPattern() {
      for (var i=0;i<rgb.length;i+=3) {
         rgb[i  ] = i*10; 
         rgb[i+1] = i*10;
         rgb[i+2] = i*10;

    for (var i=0;i<rgb.length;i+=3)
    That is the three conditions within the for loop correct? first being; var i is set to 0, the loop ends when i =25? - as thats how many rows are in my array (ie LEDs), and on each loop 3 is added to the var i?

    rgb[i ] = i*10;
    rgb[i+1] = i*10;
    rgb[i+2] = i*10;

    What is this doing? I assume its setting a value of 10 to the first RGB LED, so [10,10,10]? then the next LED would be set to [20,20,20] once the loop is completed?

    Basically, id like help understanding how I am controlling the lights with relation to this Unit8Array


Avatar for Robet @Robet started