Share My Creation A small extention to Erel's TM1637 display example

I can’t thank Erel enough. He provided us with incredibly powerful, easy-to-use, and cross-platform programming tools, supported by his unmatched technical assistance.

While this example project is not my original creation, I couldn’t find a more appropriate place on the forum to share it. I simply added a button to clock the TM1637 IC from an external source—a push button in this case. You can then use any other source to provide a clock, depending on your project's needs.

Colcking the TM1637 from external source:
Sub Process_Globals
    Public Serial1 As Serial
    Private tm As TM1637Display
    Private btn As Pin
    Private counter As Int = 0
End Sub

Private Sub AppStart
    Serial1.Initialize(115200)
    Log("AppStart")
    tm.Initialize(2, 3) ' Initialize the TM1637 using pins 2 and 3

    btn.Initialize(btn.A2, btn.MODE_INPUT_PULLUP) ' Using the internal pull-up resistor to prevent the pin from floating.
    btn.AddListener("Btn_StateChanged")
End Sub

Sub Btn_StateChanged (State As Boolean)
    If State = False Then  ' Button pressed
        ' Increase the counter and display it
        counter = counter + 1
        If counter > 99 Then counter = 0 ' Reset to 0 if the counter exceeds 99
        tm.ShowNumberDec(counter) ' Display the counter value
        Log("Counter: ", counter)
    End If
End Sub
1637exClock.png
 
Last edited:
Top