How to use TM1637 chip for LED Display?


Results 1 to 14 of 14

Threaded View

  1. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,653


    Did you find this post helpful? Yes | No

    Default Re: How to use TM1637 chip for LED Display?

    Mike is correct
    try this , it works on a 12f1822
    note leds 2,3 and 4 show random crap since nothing is written to them
    and not using lat regs is asking for trouble

    nearly forgot dispnum = 146 ' "2" (Common anode) (10010010)
    not on my display

    dispnum = $5b ' "2" (Common anode) (01011101)



    Code:
    OSCCON = %01111000 '16MHz HF, software PLL disabled
     DEFINE OSC 16
    
     'Port direction
     TRISA = %001000 'A.3 is input, rest are outputs.
    
     CM1CON0 = 0 'Disable comparator
     ANSELA = 0 'Disable A to D
    
     'List of Aliases
     LED var PortA.0
     DIO var LATA.1
     CLK var LATA.2 
     TrisDIO VAR TrisA.1
    
     'List of variables
     Cnt var byte
     ByteToSend var byte 'Command or Data byte to be sent
    
     DispCmd var byte
     dispcmd = 64 'Command byte for displaying characters starting with the leftmost digit (0b01000000)
    
     Brt8Cmd var byte
     brt8cmd = 143 'Command byte for display on with maximum brightness (0b10001111)
    
     Dig1Addr var byte
     dig1addr = 192 'Address of digit 1 (left most) (0b11000000)
    
     DispNum var byte
     dispnum = $5B' "2" (Common anode) (10010010)
    
     'Diagnostic routine
     DiagRoutine: 
     CLK=1
     for cnt = 1 to 4 'Blink LED 4 times.
     led = 1 : pause 100 
     led = 0 : pause 100
     next cnt
    
     goto start
    
     'Subroutines
     StartCondition:
     clk = 0
     dio = 1
     clk = 1
     pauseus 50
     dio = 0 'DIO goes low when CLK is high.
     pauseus 50
     return
    
     SendTheByte:
     clk = 0
     for cnt = 0 to 7   'Send 8 bits of data, starting with the LSB. 
    dio = bytetosend.0(cnt)
    pauseus 50
    clk = 1 
    pauseus 50
    clk = 0
     Next cnt
     'dio = 1 
     Trisdio = 1 ' Set Data pin direction to input to receive ACK.
     pauseus 50
     clk = 1
     pauseus 50
     clk = 0
     Trisdio = 0 ' Set Data pin direction back to output.
     return
    
     StopCondition:
     clk = 0
     dio = 0
     clk = 1
     pauseus 50
     dio = 1 'DIO goes high when CLK is high. 
     pauseus 50
     return
    
     START:
    
    
    
     bytetosend = dispcmd 'DispCmd (01000000) (64) = Command byte with auto increment sent before sending the digit data
     gosub startcondition
     gosub sendthebyte 
     gosub stopcondition
    
     bytetosend = dig1addr 'Dig1Addr (11000000) (192) = Address of digit 1 (leftmost digit)
     gosub startcondition
     gosub sendthebyte
    
     bytetosend = dispnum ' Number "2" (10010010) (146) (Common anode) 
     gosub sendthebyte
    
     gosub stopcondition
       bytetosend = brt8cmd 'Brt8Cmd (10001111) (143) = Command for Display On with Maximum Brightness
     gosub startcondition
     gosub sendthebyte
     gosub stopcondition
    
     END
    Last edited by richard; - 10th October 2018 at 14:45.
    Warning I'm not a teacher

Similar Threads

  1. TM1637 - display module include example
    By longpole001 in forum Code Examples
    Replies: 5
    Last Post: - 13th April 2020, 18:19
  2. 3642bh display module pinouts on tm1637 module
    By longpole001 in forum Schematics
    Replies: 0
    Last Post: - 31st July 2018, 18:09
  3. LED Matrix display
    By Art in forum General
    Replies: 13
    Last Post: - 5th October 2013, 04:06
  4. LED Bargraph chip (guitar LED bling-age) ..do with a PIC?
    By HankMcSpank in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 12th July 2009, 23:15
  5. TV Display Chip
    By zadok in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 17th April 2008, 22:17

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts