Using e18-d80nk Infrared and TM1637 LED Display on Arduino Uno

I am trying to create a simple counter that will utilize the e18-d80nk infrared device and display the a count for each pass on the TM1637 LED Display. I’ve pulled a bit of this from different youtuber’s and I’m sure it shows. (Robojax seems rather helpful in the explanations)

I am very new to this so I apologize in advance to any misunderstanding or misuse of the forum.

For the simple “wiring diagram”… The E18-D80NK device - Black - digital pin 8, Red - 5V, Blue - Ground. The Display - clock - digital pin 2, dio - digital pin 3, vcc - 5v (same as the infrared device), GND - Ground.

My code is below (I know its bad), seems like I am getting multiple errors. (I can see that E18-D80NK device is reading and counting within the serial monitor). I was also able to run the test program from robojax GitHub page.

The first error seems to be at the first ‘serial.print’ line… error " ‘serial’ was not declared in this scope.

#include <TM1637Display.h>   - this line is probably not needed

int ir_pin = 8;
int counter = 0;
int hitObject = false;

void setup() {

void loop() {

  int val = digitalRead(ir_pin);

  if( (val == 0) && (hitObject == false) ){
    hitObject = true;
    Serial.print("counter = ");
    Serial.println( counter);
  }else if ( (val ==1) && (hitObject == true) ) {
      hitObject = false;
  }  }

 #include <Arduino.h>
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK 2
#define DIO 3

// The amount of time (in milliseconds) between tests
#define TEST_DELAY   2000

TM1637Display display(CLK, DIO);
uint8_t blank[] = { 0x0, 0x0, 0x0, 0x0 };//


const int ir_pin = 8;
const int hitObject = false; 
const int touchDelay = 500;

int count=0;//

void setup() {
  // Lap Counter 20200104

  Serial.println("Mr Awesome Speedway");

  uint8_t data 8888[] = {0xff, 0xff, 0xff, 0xff };

  // Lap Counter 20200104

  id loop() {
  // Lap Counter 20200104

  int irValue = digitalRead(touchPin);

  // if irValue is HIGH
  if(irValue == HIGH)


    Serial.print("Lap ")
    Serial.println(" times.");

I appreciate if anyone made it this far. I’m sure the above was brutal.

I would like to expand on this to detect and display a time between passes. If it takes another display for that, that is no problem, just not sure how to wire up the additional. Is that when a bread board comes in to play? My final request is to expand this to 6 different locations, 6 different infrared detectors and 6 or 12 displays.

I’m not opposed to making a small donation to anyone’s cause willing to help me through to the end on this project.

Thank you,

There are two setup() functions in that code. Can't be good.

For starters, clean it up. All the #include to the top, then global variables, followed by your functions.

An autoformat by the IDE goes a long way as well to keep your code looking clean and be readable. It'll also show you very quickly where the missing } are (that's the common cause of an error as you mention).

Then back to basics:

  • does the display work? Use a library example, get it running. Just counting seconds or whatever.
  • does the reading of the other sensor work? Print to the Serial output.
    When both are good, time to combine sketches.