Advertisement
Zeshin

Arduino_VGRADENI_SISTEMI

Jun 26th, 2022
1,177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <SevSeg.h>
  2. SevSeg sevseg;
  3.  
  4. void setup(){
  5.   byte numDigits = 4;
  6.   byte digitPins[] = {10, 11, 12, 13};
  7.   byte segmentPins[] = {9, 2, 3, 5, 6, 8, 7, 4};
  8.  
  9.   bool resistorsOnSegments = true;
  10.   bool updateWithDelaysIn = true;
  11.   byte hardwareConfig = COMMON_CATHODE;
  12.   bool updateWithDelays = false;
  13.   bool leadingZeros = true;
  14.   bool disableDecPoint = true;
  15.   sevseg.begin(hardwareConfig, numDigits, digitPins, segmentPins, resistorsOnSegments,
  16.   updateWithDelays, leadingZeros, disableDecPoint);
  17.   sevseg.setBrightness(90);
  18. }
  19.  
  20. void loop(){
  21.     static unsigned long timer = millis();
  22.   static int deciSeconds = 0;
  23.  
  24.   if (millis() - timer >= 100) {
  25.     timer += 100;
  26.     deciSeconds++;
  27.  
  28.     if (deciSeconds == 10000) {
  29.       deciSeconds=0;
  30.     }
  31.     sevseg.setNumber(deciSeconds, 1);
  32.   }
  33.  
  34.   sevseg.refreshDisplay(); // Must run repeatedly
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement