Introduction: Stopwatch and Lap Time Counter

Picture of Stopwatch and Lap Time Counter

Hello all,

This is a very easy project to be done about a stopwatch using Arduino Nano and MAX7219 LED display (8 Digits x 7 Segments).

The stopwatch using this kind of display is new and I could not find anything like it.

The first 4 digits of display show the time count and the last 4 digits show the lap time and the maximum time count is 999.9 seconds (16 minutes & 39.9 seconds).

Take a look on Video.

Let's see it !!

Step 1: Material List

Picture of Material List
  • 1 x Arduino Nano (or similar)
  • 1x MAX7219 LED Display (8 Digits x 7 Segments)
  • 3 x Push Buttons
  • 1 x Breadboard (half size)
  • Wires

The MAX7219 is very simple to be used and you need only 3 data pins to connect to Arduino.

With this configuation using the Arduino Nano, we have a more compact package.

Step 2: Schematic

Picture of Schematic

The assembly of components is very simple.

Just follow the schematic with care about wiring connections.

Step 3: Programming

The program was developed for Arduino Nano but you can use it for Arduino Uno too.

You will need to include in your Arduino two libraries:

  • Bounce2.h (Bounce is a library for Arduino. It debounces digital inputs and more.)

Note: With minor changes you can adapt this program to ATtiny85 microcontroller too.

/* Stopwatch with Arduino Nano
(Double LED Display - 4 Digits x 7 Segments) V1.0 - 28.Jun.2016 by LAGSILVA */

#include // Library for LED control with MAX72XX #include // Library for Bounce of switches

/* Pins of Arduino Nano for LedControl: Pin #7 is connected to DataIn (DIN) Pin #8 is connected to CLK (CLK) Pin #9 is connected to LOAD (CS) There are one double display with MAX72XX.

LedControl(int dataPin, int clkPin, int csPin, int numDevices)*/ LedControl lc = LedControl(7, 8, 9, 1);

int k, lastTime, diffTime; int milhar, centena, dezena, unidade; int milhar1, centena1, dezena1, unidade1;

int pinStartStop = 4; // Start-Stop Pin int pinLapse = 3; // Time Lapse Pin

bool statusSwitch1 = false;

Bounce SW1 = Bounce(); // Define Bounce to read StartStop switch Bounce SW2 = Bounce(); // Define Bounce to read Lapse switch

void setup() {

pinMode (pinStartStop, INPUT_PULLUP); pinMode (pinLapse, INPUT_PULLUP);

// After setting up the button, setup the Bounce instance SW1.attach(pinStartStop); // Sets the pin (Internal Pull-Up)and matches the internal state to that of the pin SW1.interval(4); // Sets the debounce time in milliseconds SW2.attach(pinLapse); SW2.interval(4);

lc.shutdown(0, false); // The MAX72XX is in power-saving mode on startup, we have to do a wakeup call lc.setIntensity(0, 5); // Set the brightness of display between 0 and 15 lc.clearDisplay(0); // Clear the display

lc.setDigit(0, 7, 0, false); lc.setDigit(0, 6, 0, false); lc.setDigit(0, 5, 0, true); lc.setDigit(0, 4, 0, false);

lc.setDigit(0, 3, 0, false); lc.setDigit(0, 2, 0, false); lc.setDigit(0, 1, 0, true); lc.setDigit(0, 0, 0, false);

}

void loop() {

lastTime = 0; diffTime = 0;

for (k = 0; k <= 9999; k++) {

SW1.update();

if (SW1.fell()) { statusSwitch1 = !statusSwitch1; }

if (statusSwitch1 == true) {

milhar = k / 1000; centena = (k - milhar * 1000) / 100; dezena = (k - milhar * 1000 - centena * 100) / 10; unidade = k % 10;

lc.setDigit(0, 7, milhar, false); lc.setDigit(0, 6, centena, false); lc.setDigit(0, 5, dezena, true); lc.setDigit(0, 4, unidade, false); } else { k = k - 1; }

SW2.update();

if (SW2.fell()) {

diffTime = k - lastTime; lastTime = k;

milhar1 = diffTime / 1000; centena1 = (diffTime - milhar1 * 1000) / 100; dezena1 = (diffTime - milhar1 * 1000 - centena1 * 100) / 10; unidade1 = diffTime % 10;

lc.setDigit(0, 3, milhar1, false); lc.setDigit(0, 2, centena1, false); lc.setDigit(0, 1, dezena1, true); lc.setDigit(0, 0, unidade1, false);

}

delay(99);

}

}

Step 4: Using

Picture of Using

There are three push buttons with the following functions:

  1. Reset the display (1st switch on left)
  2. Start / Stop the Stopwatch (2nd switch at middle)
  3. Show the lap time (3rd switch on right)

The running time in tenths of seconds is shown at first 4 digits on left of display.

The lap time is shown at last 4 digits on right of display.

Note:

If you want, it is possible to change the Start/Stop and the Lap time buttons for sensors like LDR, for example, to giving you an automated way to control the stopwatch.

Comments

Odilond (author)2016-07-25
  • 1x Maxi 7219 LED Display (4 Digits x 7 Segments)???
  • 8 Dígitos x 7 Segments
lagsilva (author)Odilond2016-07-25

8 digits X 7 segments.
Tks for warning!

About This Instructable

1,831views

13favorites

License:

Bio: I am a Mechanical Engineer and an enthusiastic Maker. I like to develop new ideas combining electronics and programming.
More by lagsilva:Digital Clock With Mirrored Display Driven by AccelerometersAnalog Clock With LED Matrix and ArduinoChinese Rings Puzzle
Add instructable to: