OPTO Interrupter Counter
Pickup Winder 2.0

       In this video I show how I am using an Arduino to count rotations on a motor by using an Ardunio Nano a TM1637 Display and an OPTO Interrupter switch. Ill be using this setup to build a counter for a pickup winder but it can be used for many other purposes. Hope you enjoy.

My Channel

Parts List and Downloads:

Arduino Nano Boards

OPTO Sensors

TM1637 Display

DISCLAIMER: This video and product links on this website contain affiliate links with Amazon Associates Program. As an Amazon Associate I earn from qualifying purchases. When you click on a link I receive a small commission. This helps support the channel and allows me to continue to make videos like this. Thank you for the support!

Arduino IDE Download

TM1637 Library Link

You will need to install the libraries for the TM1637 Display into your Arduino’s IDE Libraries folder in order for the code to work.  Details for this in the video.

Code for this Project:

// Author: Silverjoda
// 4/8/2015
// Edited By Chase’sWKshop
// 12/11/2018
// Target: Arduino
#include <TM1637Display.h>

// Module connection pins (Digital Pins)
#define CLK 6
#define DIO 7

// The amount of time (in milliseconds) between tests
#define TEST_DELAY 100
uint8_t data[] = { 0xff, 0xff, 0xff, 0xff };

TM1637Display display(CLK, DIO);

// Code uses external interrupt to count the incoming pulses.

volatile int counter = 0;

void setup() {
Serial.begin(9600);
display.setBrightness(0x0f);
attachInterrupt(0,count,RISING);
}

void loop() {
delay(10); 
Serial.print(counter); // Counter

display.showNumberDec(counter, true); // Expect: 0000
delay(TEST_DELAY);

}

void count()
{
counter++;
}