#include <TM1637.h>

int CLK = 2;
int DIO = 3;
int counter = 0;
int redPin = 11;
int greenPin = 10;
int bluePin = 9;
TM1637 tm(CLK, DIO);
void setup() {
  // put your setup code here, to run once:
  tm.init();
  tm.set(BRIGHT_TYPICAL);
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  tm.display(0, (counter / 1000) % 10);
  tm.display(1, (counter / 100) % 10);
  tm.display(2, (counter / 10) % 10);
  tm.display(3, counter % 10);
  counter++;
if(counter>=0 &&counter<100){
  analogWrite(redPin, 255);
  analogWrite(greenPin,0 );
  analogWrite(bluePin, 0);
}
if(counter>=100 &&counter<200){
  analogWrite(redPin, 0);
  analogWrite(greenPin,255 );
  analogWrite(bluePin, 0);
}
if(counter>=200 &&counter<300){
analogWrite(redPin, 0);
  analogWrite(greenPin, 0);
  analogWrite(bluePin, 255);
}
if(counter==300){
      counter=0;
}

  

  delay(100);
}


4-Digit Display