LED&KEY module

I've had one of these http://www.alselectro.com/7-segment-led-array---key---ic-tm1638-drive.html for a while and when I tried to use it had trouble getting anything to display. So I played with it and looked for some example SPIN code to use with it but only found a couple online that didn't work for me anyway. More playing and things started to click. So I've written a few simple programs to use the basic display options and thought I would post this to help someone else trying to get started. Also included a readme with some of what I have learned. I have nowhere near learned to use this to even part of it's potential and may post more when more is known. Hope this helps someone!
Aaron

Comments

  • JonnyMacJonnyMac Posts: 6,595
    edited 2019-12-20 - 02:16:38
    After seeing your post I thought it would be something worth having a proper library for. Most of the code I encountered was for the Arduino, and most of that was, well, garbage (Why do Arduino users torture each other with bad code? :smiley: )

    Anyway, I spent a day writing what I think is a proper library for the LED&KEY.

    I've attached a demo that shows off the features:
    -- write segments to any column
    -- write a hex digit to any column
    -- write a character to any column (limited by 7-segment displays)
    -- write the state of any led -- or all at once from a single byte
    -- fill the 7-segment displays and leds with desired pattern/state
    -- write a string (limited by 7-segment displays)
    -- write a decimal value (left justified)
    -- write a right-justified decimal value
    -- write a fixed-point decimal value
    -- write variable- or fixed-width hex value
    -- write variable- or fixed-width binary value
    -- read buttons

    If anyone finds a problem with the library, please let me know.

    I have ordered the version with eight 7-segment displays and 16 buttons. Will post code for it when it arrives and I've had time to play with.

    Code updated: 19 DEC 2019
  • Jon
    I got the idea to try to make use of this thing from this video
    part 3
    https://www.bing.com/videos/search?q=youtube+clough42+electronic+lead+screw&&view=detail&mid=2B6239CA4D7F38750E1B2B6239CA4D7F38750E1B&&FORM=VDRVRV
    Not to do the exact thing but to be able to switch to read several different outputs by using the buttons, indicating LEDs and 7segs.
    Thanks
    Aaron
  • JonnyMac wrote: »
    I have ordered the version with eight 7-segment displays and 16 buttons.
    Where did you find one with 16 buttons? I could only find ones with 8.

  • @Aaron That guy did a nice job on the case. I do a lot of coding for escape room puzzles and thought this board would be a good electronic lock interface. My problem with most of the Arduino code I found is that it was just fragments, not a full driver that would allow a new programmer (I'm not) to use the board to its full potential -- and do it easily. I think you'll find my driver does that.

    @David It's an eBay find. If you do a search on TM1638 (the driver chip) you'll find a bunch. Here's the one I bought (I tend to stick to US suppliers):

    -- https://www.ebay.com/itm/8-Bits-LED-Digital-tube-Module-Keyboard-Scan-and-Display-Module-TM1638-MCU/333348385691

    This version lacks the discrete LEDs of the smaller one -- that's okay with me.
  • Thanks, Jon!
  • Today I received a TM1638 module marked JY-MCU that uses Red/Green LEDs, so I have modified my driver and demo to accommodate it. The new code is in my original post.
  • After working with the TM1637 for a couple days I went back to the TM1638 and made some improvements
    -- str() is faster and handles decimal points appropriately
    -- wr_leds() and paint_leds() are faster

    Updated code is posted above.
  • Hi Jon -

    Have you tried updating your object to work with the P2?

    I've had success with the display, but cannot read the buttons, whether or not I do a pullup resistor on the DIO line. It looks like the P2 is sinking the current from the pullup and not allowing the line to go high.

    Thanks,

    Walter
  • Actually, I may do that today. I have been busy with smart pins the past few days. Smart pins can do SPI, too, but I will use the P2 version of my P1 SPI (bit-bang) driver as it's plenty fast (tested up to 10MHz with MAX7219 display).
  • Found that my issue was that I needed to use PINFLOAT() on the DIO pin. Now I see the buttons.

    Still looking forward to your driver. Mine is wonky.
  • JonnyMacJonnyMac Posts: 6,595
    edited 2020-03-16 - 05:34:56
    Got it working! I had trouble with the buttons, too, but mine was an error having to do with reversing the bits in PASM2.
    Posted here:
    -- http://forums.parallax.com/discussion/171327/p2-tm1638-driver-and-demo/
Sign In or Register to comment.