• Hi everyone,
    I would like to know if my Charlieplexed LED matrix needs to be arranged in a specific way to work.
    For example, do I need to go top to bottom and left to right? or bottom to top and right to left? or bottom to top and left to right? Does it even matter? And if I get my arrangement wrong, can I still display graphics the right way up by rotating the graphics?

    Thanks!

    EDIT: Also, can the charlieplex library display text and images as long as I provide the width and length? Or do I need to arrange my LEDs in a certain width/height to use the bitmap fonts? Thanks again!

  • Hi - it shouldn't really matter. I think generally Graphics expects the pixels start in the top-left and scan across and then down, but you can fix any rotation and mirroring that's needed with g.setRotation.

    The Charlieplex library does expect that the LEDs are going to be arranged in a N*N-1 pattern though - so if you do something different then the underlying code would need changing... However I doubt doing that is as mind-bending as it would be trying to wire up something that wasn't N*N-1...

    And yes, as long as the Graphics library has the pixels in the right places it'll be fine to display text.

    How big a Charlieplexed pattern were you thinking of doing with it?

  • I'm designing a 6x5 LED matrix for simple scrolling text and graphics. It's for the second iteration of my watch!

  • Oh another question, how do I turn a function on and off using only one button?
    For now I have individual on/off buttons but I would like to use just one.
    I've tried var l;function(l=!l) and similar methods but they all don't seem to work.

    pinMode(B8, 'input_pullup');
    pinMode(B5, 'input_pullup');
    
    function random(state) {
      
      if (state === true || state === 1) {
        random();
      } else if (state === false || state === 0) {
        allClear();
        clearTimeout();
        setDeepSleep(1);
        return;
      }
      
      digitalWrite(A8, 0);
      digitalWrite(B7, 0);
      
      //var num = Math.floor((Math.random() * 10));
      //var sec = ((Math.random() * 0.5) + 1) * 1000;
      var what = Math.floor((Math.random() * 3));
      
      if (what === 0) {
        allClear();
      }
      else if (what == 1 || what == 2) {
        digitalWrite(A, Math.floor((Math.random() * 2)));
        digitalWrite(B, Math.floor((Math.random() * 2)));
        digitalWrite(C, Math.floor((Math.random() * 2)));
        digitalWrite(D, Math.floor((Math.random() * 2)));
        digitalWrite(E, Math.floor((Math.random() * 2)));
        digitalWrite(F, Math.floor((Math.random() * 2)));
        digitalWrite(G, Math.floor((Math.random() * 2)));
      }
    
      setTimeout(random, ((Math.random() * 701) + 1));
      
      setWatch( function(e) {
        random(false);
      }, B8, {repeat:true, edge:'falling', debounce:100});
      
    }
    
    setWatch( function(e) {
      clearTimeout();
      random(true);
    }, B5, {repeat:true, edge:'falling', debounce:100});
    
    setDeepSleep(1);
    
  • Awesome - yeah, 6x5 should work fine. The way the scanning works for the Charlieplexing it should actually be reasonably power efficient running at 50Hz update or so.

  • I'm not sure I understand? You want to just flip the state of a boolean value when a button is pressed? If so something like this should be fine:

    var l = false;
    setWatch( function(e) { l=!l; }, B5, {repeat:true, edge:'falling', debounce:100});
    
  • Thanks! Will multiplexing ever be supported in Espruino? Just curious.

  • multiplexing?

  • Yeah, where you can control an X by Y matrix with (X+Y) pins. I'm just more used to it, that's all.

  • Yes, you can do that really easily if you want to - because there wasn't anything very clever required I hadn't even made a module for it.

    I'll add that to my list of things to do though - but I'm happy to post up some example code here if you need a hand.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Does a charlieplexed LED matrix require a specific order of LEDs?

Posted by Avatar for Marty_McFly @Marty_McFly

Actions