LED&KEY module
AGCB
Posts: 330
in Propeller 1
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
Aaron
Comments
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
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
@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.
-- str() is faster and handles decimal points appropriately
-- wr_leds() and paint_leds() are faster
Updated code is posted above.
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
Still looking forward to your driver. Mine is wonky.
Posted here:
-- http://forums.parallax.com/discussion/171327/p2-tm1638-driver-and-demo/