Advertisement
microrobotics

TM1637 4X7 Segment LED Display

Apr 26th, 2023
2,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. To control a TM1637 4x7 segment LED display with a colon separator and size 30x14mm (0.35") using an Arduino, you can follow the steps below:
  3.  
  4. Install the TM1637 library. You can download it from the Arduino Library Manager, or from the following GitHub repository: https://github.com/avishorp/TM1637. Follow the instructions on the repository to install the library.
  5.  
  6. Connect the TM1637 display to the Arduino:
  7.  
  8. VCC pin to the 5V pin on the Arduino
  9. GND pin to the GND pin on the Arduino
  10. DIO (Data) pin to a digital pin on the Arduino (e.g., pin 2)
  11. CLK (Clock) pin to another digital pin on the Arduino (e.g., pin 3)
  12. Upload the following code to your Arduino board:
  13.  
  14. This example code will display the number 1234 on the TM1637 display with the colon separator enabled. You can change the number variable to display a different number or implement your own logic to update the displayed number.
  15. */
  16.  
  17. #include <Arduino.h>
  18. #include <TM1637Display.h>
  19.  
  20. // Pin connections for the TM1637 display
  21. const int CLK = 2;
  22. const int DIO = 3;
  23.  
  24. // Create a TM1637 display object
  25. TM1637Display display(CLK, DIO);
  26.  
  27. // Example number to display
  28. int number = 1234;
  29.  
  30. void setup() {
  31.   // Set the display's brightness (0 to 7)
  32.   display.setBrightness(7);
  33. }
  34.  
  35. void loop() {
  36.   // Display the number
  37.   display.showNumberDec(number, true); // The second parameter "true" enables the colon separator
  38.  
  39.   // Wait for a while
  40.   delay(1000);
  41.  
  42.   // You can add your own logic here to update the displayed number or implement other functionality
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement