Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include "TM1637.h"
  2. #define CLK 3//pins definitions for the module and can be changed to other ports
  3. #define DIO 2
  4. #define button 10
  5. #define button2 11
  6. int number = 0;
  7. int bright = 0;
  8.  
  9.  
  10. TM1637 disp(CLK, DIO);
  11. void setup()
  12. {
  13. disp.set(BRIGHT_TYPICAL);//BRIGHT_TYPICAL = 2,BRIGHT_DARKEST = 0,BRIGHTEST = 7;
  14. disp.init(D4056A);//D4056A is the type of the module
  15.  
  16. pinMode(button, INPUT);
  17. pinMode(button2, INPUT);
  18.  
  19. Serial.begin(9600);
  20. }
  21. void loop()
  22. {
  23. if (!digitalRead(button))
  24. {
  25. number ++;
  26. disp.display(0, number);
  27. delay(200);
  28. }
  29.  
  30. if (digitalRead(button2) == 0) {
  31.  
  32. bright++;
  33. if(bright > 7)bright = 0;
  34. disp.set(bright);
  35. disp.display(0, number);
  36. delay(200);
  37. }
  38. // {
  39. // disp.clearDisplay()
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement