TM1637.h randomely fails

Hello, I could use some help w/ the TM1637.h library. It seems to randomely create issue when trying to save or upload sketches. Any help would be greatly appreciated. I've copied in my full code. To keep this clean, i'll post the error in a follow up message.

/*
Current version includes BLE Control code and Millis based clock.
*/


#include <ArduinoBLE.h>

int blueLedPin = 14;
int greenLedPin = 15;
int whiteLedPin = 16;
int redLedPin = 17;

byte signal1Value = 0;
byte oldSignal1Value = 0;
byte signal2Value = 1;
byte oldSignal2Value = 1;

const String periphID = "19B10000-E8F2-537E-4F6C-D104768A1214";
bool debug = 0; //Set to 1 and connect to serial monitor for debug mode
bool debug2 = 0; //Set to 1 to allow peripheral to continue sending values and for clock to keep going.  1 is the normal mode.

#include <TM1637.h>

int CLK = 3;
int DIO = 2;
TM1637 tm(CLK,DIO);

const int addMinute = 10; 
const int subMinute = 11;
const int startWin = 12;
const int buzzer = 21;

int addMinuteCurrent = 1;
int subMinuteCurrent = 1;
int startWinCurrent = 1;
int addMinutePrior = 1;
int subMinutePrior = 1;
int startWinPrior = 1;

int startMin = 60;
int startSec = 00;
int minRemaining = 00;
int secRemaining = 00;
int countDown = 0;
int clkDelay = 1000;
unsigned long priorClockEvent = 0;
unsigned long buzzerStart = 0;

String str1 = String(startMin) + "00";

//*** SETTINGS ***
int gameStatus = 1; // 11 = Game Won, 10 = Jeapordy, 1 = Continue, 0 = Game Lost
const int autoWin = 1;  // if 1, clock stops with solved game status
int clockSetupMode = 0;
int priorClockSetupMode = 0;


void setup() {  //Clock Setup
  pinMode(addMinute, INPUT_PULLUP);
  pinMode(subMinute, INPUT_PULLUP);
  pinMode(startWin, INPUT_PULLUP);
  pinMode(buzzer, OUTPUT);
  
  pinMode(blueLedPin, OUTPUT); 
  pinMode(greenLedPin, OUTPUT); 
  pinMode(whiteLedPin, OUTPUT); 
  pinMode(redLedPin, OUTPUT);

  tm.init();
  tm.setBrightness(5);
  tm.colonOn();
  tm.display(str1);
  Serial.begin(9600);
  if (debug) {while (!Serial);} 
  
  digitalWrite(redLedPin, HIGH);
  
  while (!countDown) { //try moving setupClock to setup section of code
    setupClock();
  }
  
  BLE.begin();// initialize the Bluetooth® Low Energy hardware
  Serial.println("Bluetooth® Low Energy Central - LED control");
  BLE.scanForUuid(periphID); // start scanning for peripherals
}

void loop(){
  while (countDown) {
    Serial.println("countdown timer on"); //Code update needed... Don't reprint this unless the timer status changes (happens if no device is connected and the clock doesn't run)
    digitalWrite(whiteLedPin, LOW);
    digitalWrite(redLedPin, HIGH);
    BLEDevice peripheral = BLE.available(); // check if a peripheral has been discovered
  
    if (peripheral) { 
      Serial.println("peripheral found");
      BLE.stopScan(); 
      readCharacteristics(peripheral); 
      BLE.scanForUuid(periphID); // peripheral disconnected, start scanning again
    }
  }
  
  //DEV OPPORTUNITY: should this maintain peripheral connection even if timer is off???
}
 
void setupClock() {
  if (round(millis()/1000)%2) {digitalWrite(whiteLedPin, HIGH);}
  else (round(millis()/1000)%2) {digitalWrite(whiteLedPin, LOW);}

  addMinuteCurrent = digitalRead(addMinute);
  if (addMinuteCurrent != addMinutePrior) {
    if (!addMinuteCurrent) {
      startMin +=1;
      Serial.println("add minute");
      prntStr();
      buzz(100);
      delay(150);
    } 
  }
  addMinutePrior = addMinuteCurrent;
  
  subMinuteCurrent = digitalRead(subMinute);
  if (subMinuteCurrent != subMinutePrior) {
    if (!subMinuteCurrent) {
      startMin -=1;
      Serial.println("subtract minute");
      prntStr();
      buzz(100);
      delay(150);
    }
  }
  subMinutePrior = subMinuteCurrent;
  
  startWinCurrent = digitalRead(startWin);
  if (startWinCurrent != startWinPrior) {
    if (!startWinCurrent) {
      buzz(250);
      buzz(250); 
      buzz(250);
      delay(150);
      countDown = 1; //Count down started
      digitalWrite(whiteLedPin, LOW);
      Serial.println("start game");
      priorClockEvent = millis();
    } 
  }
  startWinPrior = startWinCurrent;
}

void runClock() {
  startWinCurrent=digitalRead(startWin);
  
  if ((!startWinCurrent and gameStatus==11) or (!startSec and !startMin)) {
    endGame();
  } 
  
  if (millis() >= priorClockEvent + clkDelay) {
    priorClockEvent += clkDelay;
    if (!startSec and startMin) {
      startMin-=1;
      startSec=59;
      prntStr(); 
    } else {
      startSec-=1;
      prntStr();
    }
  }
}
 
void prntStr() {
  if (startMin >= 10 and startSec >= 10) {
    str1 = String(startMin) + String(startSec);
  } else if (startMin >= 10 and startSec < 10) {
    str1 = String(startMin) + "0" + String(startSec);
  } else if (startMin < 10 and startSec >= 10) {
    str1 = " " + String(startMin) + String(startSec);
  } else {
    str1 = " " + String(startMin) + "0" + String(startSec);
  }
  tm.display(str1);
}


void buzz(int ms) {
  buzzerStart = millis();
  while (millis() <= buzzerStart + ms) {
    digitalWrite(buzzer,HIGH);
  }
  digitalWrite(buzzer,LOW);
}
 
void endGame() {
  if (!debug2) {
    buzz(150);
    buzz(150);
  }
  prntStr();
  countDown = 0;
  blinkClock();
}

void blinkClock() {
  while (debug2) {
    buzzerStart = millis();
    while (millis() <= buzzerStart + 750) {
      tm.display(str1);
    }
    buzzerStart = millis();
    while (millis() <= buzzerStart + 250) {
      tm.display("    ");
    }
  }
}

void readCharacteristics(BLEDevice peripheral) {
  peripheral.connect();
  peripheral.discoverAttributes();

  BLECharacteristic signal1 = peripheral.characteristic("19b10001-e8f2-537e-4f6c-d104768a1214"); 
  BLECharacteristic signal2 = peripheral.characteristic("19b10002-e8f2-537e-4f6c-d104768a1214"); 

  while (peripheral.connected()) { 
    signal1.readValue(signal1Value); 
    if (oldSignal1Value != signal1Value) {oldSignal1Value = signal1Value;}
    Serial.print(signal1Value);
    Serial.println(" = Signal 1 Value");
    
    signal2.readValue(signal2Value); 
    if (oldSignal2Value != signal2Value) {oldSignal2Value = signal2Value;}  
    Serial.print(signal2Value);
    Serial.println(" = Signal 2 Value");
    
    if (signal1Value && signal2Value) { //WIN GAME
      digitalWrite(blueLedPin, LOW);
      digitalWrite(greenLedPin, HIGH);
      digitalWrite(whiteLedPin, LOW);
      digitalWrite(redLedPin, LOW);
      gameStatus = 11;
      Serial.println("gameStatus = 11 - Win Game");
      if (autoWin) {endGame();}
      clkDelay = 1000;
    }
    else if (signal1Value && !signal2Value) { //GAME AT RISK
      digitalWrite(blueLedPin, HIGH);
      digitalWrite(greenLedPin, LOW);
      digitalWrite(whiteLedPin, HIGH);
      digitalWrite(redLedPin, LOW);
      gameStatus = 10;
      Serial.println("gameStatus = 10 - Jeopardy");
      clkDelay = 500;
    }
    else if (!signal1Value && signal2Value) { //CONTINUE GAME
      digitalWrite(blueLedPin, LOW);
      digitalWrite(greenLedPin, LOW);
      digitalWrite(whiteLedPin, HIGH);
      digitalWrite(redLedPin, LOW);
      gameStatus = 1;
      Serial.println("gameStatus = 01 - Continue Game");
      clkDelay = 1000;
    }
    else if (!signal1Value && !signal2Value) { //LOSE GAME
      digitalWrite(blueLedPin, LOW);
      digitalWrite(greenLedPin, LOW);
      digitalWrite(whiteLedPin, LOW);
      digitalWrite(redLedPin, HIGH);
      gameStatus = 0;
      Serial.println("gameStatus = 00 - Lose Game");
      buzz(1000);
      endGame();
    }
    
    runClock();
  }
  Serial.println("Peripheral disconnected");
}

Here is the error

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:26:18: error: no matching function for call to 'TM1637::TM1637(int&, int&)'

TM1637 tm(CLK,DIO);

^

In file included from /tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:22:0:

/home/builder/Arduino/libraries/tm1637_rt_0_4_0/TM1637.h:29:3: note: candidate: TM1637::TM1637()

TM1637();

^~~~~~

/home/builder/Arduino/libraries/tm1637_rt_0_4_0/TM1637.h:29:3: note: candidate expects 0 arguments, 2 provided

/home/builder/Arduino/libraries/tm1637_rt_0_4_0/TM1637.h:26:7: note: candidate: constexpr TM1637::TM1637(const TM1637&)

class TM1637

^~~~~~

/home/builder/Arduino/libraries/tm1637_rt_0_4_0/TM1637.h:26:7: note: candidate expects 1 argument, 2 provided

/home/builder/Arduino/libraries/tm1637_rt_0_4_0/TM1637.h:26:7: note: candidate: constexpr TM1637::TM1637(TM1637&&)

/home/builder/Arduino/libraries/tm1637_rt_0_4_0/TM1637.h:26:7: note: candidate expects 1 argument, 2 provided

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino: In function 'void setup()':

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:69:6: error: 'class TM1637' has no member named 'init'

tm.init();

^~~~

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:71:6: error: 'class TM1637' has no member named 'colonOn'

tm.colonOn();

^~~~~~~

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:72:6: error: 'class TM1637' has no member named 'display'; did you mean 'displayRaw'?

tm.display(str1);

^~~~~~~

displayRaw

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino: In function 'void setupClock()':

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:106:27: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator%'

if (round(millis()/1000)%2) {digitalWrite(whiteLedPin, HIGH);}

~~~~~~~~~~~~~~~~~~~~^~

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:107:29: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator%'

else (round(millis()/1000)%2) {digitalWrite(whiteLedPin, LOW);}

~~~~~~~~~~~~~~~~~~~~^~

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino: In function 'void prntStr()':

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:179:6: error: 'class TM1637' has no member named 'display'; did you mean 'displayRaw'?

tm.display(str1);

^~~~~~~

displayRaw

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino: In function 'void blinkClock()':

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:205:10: error: 'class TM1637' has no member named 'display'; did you mean 'displayRaw'?

tm.display(str1);

^~~~~~~

displayRaw

/tmp/1378093742/2_18_draft_game_clock/2_18_draft_game_clock.ino:209:10: error: 'class TM1637' has no member named 'display'; did you mean 'displayRaw'?

tm.display(" ");

^~~~~~~

displayRaw

Multiple libraries were found for "ArduinoBLE.h"

Used: /home/builder/opt/libraries/arduinoble_1_3_6

Not used: /home/builder/opt/libraries/vega_arduinoble_1_0_0

Multiple libraries were found for "TM1637.h"

Used: /home/builder/opt/libraries/tm1637_rt_0_4_0

Not used: /home/builder/opt/libraries/grove_4_digit_display_1_0_0

Not used: /home/builder/opt/libraries/tm1637_driver_2_2_1

Not used: /home/builder/opt/libraries/tm16xx_leds_and_buttons_0_5_2110

Not used: /home/builder/opt/libraries/7segment_1_0_2

Error during build: exit status 1

Here is the other error that comes up

/tmp/1752879258/2_18_draft_game_clock/2_18_draft_game_clock.ino: In function 'void setupClock()':

/tmp/1752879258/2_18_draft_game_clock/2_18_draft_game_clock.ino:106:27: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator%'

if (round(millis()/1000)%2) {digitalWrite(whiteLedPin, HIGH);}

~~~~~~~~~~~~~~~~~~~~^~

/tmp/1752879258/2_18_draft_game_clock/2_18_draft_game_clock.ino:107:29: error: invalid operands of types '__gnu_cxx::__enable_if<true, double>::__type {aka double}' and 'int' to binary 'operator%'

else (round(millis()/1000)%2) {digitalWrite(whiteLedPin, LOW);}

~~~~~~~~~~~~~~~~~~~~^~

Multiple libraries were found for "ArduinoBLE.h"

Used: /home/builder/opt/libraries/arduinoble_1_3_6

Not used: /home/builder/opt/libraries/vega_arduinoble_1_0_0

Multiple libraries were found for "TM1637.h"

Used: /home/builder/opt/libraries/tm1637_driver_2_2_1

Not used: /home/builder/opt/libraries/7segment_1_0_2

Not used: /home/builder/opt/libraries/grove_4_digit_display_1_0_0

Not used: /home/builder/opt/libraries/tm16xx_leds_and_buttons_0_5_2110

Not used: /home/builder/opt/libraries/tm1637_rt_0_4_0

Error during build: exit status 1

Your compiler is finding two instances of the library, you need to either remove or rename the one you do not want to use.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.