Hello, new to arduino here. Im tryin to make a project where I have 4 tm1637 displays workin at the same time. One has a clock and the other 3 are counters. Im only concerned with the clock and one counter for now. I have the clock and counter but I cant make them work properly, each on their own works fine. Once I include the clock, the counter stops working. Here's the code
#include <Arduino.h>
#include <TM1637Display.h>
#include "SevenSegmentTM1637.h"
#include "SevenSegmentExtended.h"
// Module 1 connection pins (Digital Pins)
#define CLK1 22
#define DIO1 33
// Module 2 connection pins (Digital Pins)
#define CLK2 24
#define DIO2 35
// Module 3 connection pins (Digital Pins)
#define CLK3 26
#define DIO3 37
// Module 4 connection pins (Digital Pins)
#define CLK4 28
#define DIO4 39
SevenSegmentExtended display1(CLK1, DIO1);
const unsigned int clockSpeed = 67; // speed up clock for demo
TM1637Display display2(CLK2, DIO2);// define dispaly 1 object
TM1637Display display3(CLK3, DIO3);// define dispaly 1 object
TM1637Display display4(CLK4, DIO4);// define dispaly 1 object
uint8_t data[] = {0x0, 0x0, 0x0, 0x0 }; // all segments clear
// run setup code
void setup()
{
Serial.begin(9600); // initializes the Serial connection @ 9600 baud
display1.begin(); // initializes the display
display1.setBacklight(100); // set the brightness to 100 %
delay(0000); // wait 1000 ms
display2.setBrightness(0x0f);// set brightness of dispaly 1
display3.setBrightness(0x0f);// set brightness of dispaly 1
display4.setBrightness(0x0f);// set brightness of dispaly 1
display2.setSegments(data);// // fill display 2 with whatever data[] array has
display3.setSegments(data);// // fill display 3 with whatever data[] array has
display4.setSegments(data);// // fill display 4 with whatever data[] array has
pinMode(4,INPUT);
display2.setBrightness(6);
pinMode(3,INPUT);
display2.setBrightness(6);
}
int numb=0;
int pres=0;
void loop(){
display4.showNumberDec(numb,false, 4,4);
if(numb<100)
{
if(digitalRead(4)==1)
{
if(pres==0)
{
++numb;
pres=1;
}
}
else
{
pres=0;
}
}
//inicio resta
delay(100);
if(numb>0)
{
if(digitalRead(3)==1)
{
if(pres==0)
{
--numb;
pres=1;
}
}
else
{
pres=0;
}
}
{
byte hours = 00; // initialize hours
byte minutes = 00; // initialize minutes
for ( ; hours < 90; hours++) { // count hours up to 90
for ( ; minutes < 60; minutes++) { // count minutes up to 59
display1.printTime(hours, minutes, true); // display time
delay(60000 / clockSpeed); // clock delay ms
};
minutes = 0; // reset minutes
}
}
}