-----

This project is a good beginner

Arduino project. I wanted a digital timer in my gym that counted up from 00 to 60 seconds and reset. Since I had a spare Arduino Nano and a dual 7-segment display (rescued from a

guitar effect pedal) I decided to build my own instead of driving to

Wal-Mart.

-----

If you are not interested in the details and just want to see the result, check out the video below. If you watch more than the first 10-15 seconds then you should seriously consider getting

hobby. ;)

-----

The dual 7-segment display pinout looks like this. The Arduino Nano has 14 digital outputs and you will need them all. Note: You will have to disconnect D0 and D1 from the dual 7-segment display to get reliable program uploads to the Arduino because these pins double as the USB data connection to your PC.

Not the best

documentation, but hook up is pretty straight forward. Each segment is labeled 'A' through 'G' with a "t" suffix for 'tens place' and an 'o' suffix for 'ones place'. Next to each of the 14 labeled segments is the digital pin on the Arduino that that segment is connected to; D0 through D13.

-----

And here is the code. Total project including wiring took a bit over two hours and I am a slow coder.

/*

**************************************

***** www.WhiskeyTangoHotel.Com *****

**************************************

Project Name: Gym Counter Timer

Start Date: July 26, 2014

Program Rev History and Notes:

Simple timer to count up 60 secs then reset.

LEDS are active LOW. Low turns the segment on.

LEDS came from old Zoom guitar effects pedal.

NOTE: DISCONNECT D0 AND D1 TO PREVENT U/L ERRORS

***************************************

*/

//All 14 digi pins are needed as outputs to drive two 7-seg displays. Assign aliases

// standard a-g labeling on the 7-segs. The decmial point (DP) is not used.

int a_ones = 0;

int b_ones = 1;

int c_ones = 2;

int d_ones = 3;

int e_ones = 4;

int f_ones = 5;

int g_ones = 6;

int a_tens = 7;

int b_tens = 8;

int c_tens = 9;

int d_tens = 10;

int e_tens = 11;

int f_tens = 12;

int g_tens = 13;

int i;

//**************************************

void setup() // Functions here

{

// Define all digi pins as OUTPUT

pinMode(a_ones, OUTPUT);

pinMode(b_ones, OUTPUT);

pinMode(c_ones, OUTPUT);

pinMode(d_ones, OUTPUT);

pinMode(e_ones, OUTPUT);

pinMode(f_ones, OUTPUT);

pinMode(g_ones, OUTPUT);

pinMode(a_tens, OUTPUT);

pinMode(b_tens, OUTPUT);

pinMode(c_tens, OUTPUT);

pinMode(d_tens, OUTPUT);

pinMode(e_tens, OUTPUT);

pinMode(f_tens, OUTPUT);

pinMode(g_tens, OUTPUT);

// Arduino wakes up with pins low. Set them HI to turn off the LEDS

all_off();

i = 200; // 200 'feels right'. Self test count delay from "00" to "99"

zero_ones();

zero_tens();

delay(i);

all_off();

one_ones();

one_tens();

delay(i);

all_off();

two_ones();

two_tens();

delay(i);

all_off();

three_ones();

three_tens();

delay(i);

all_off();

four_ones();

four_tens();

delay(i);

all_off();

five_ones();

five_tens();

delay(i);

all_off();

six_ones();

six_tens();

delay(i);

all_off();

seven_ones();

seven_tens();

delay(i);

all_off();

eight_ones();

eight_tens();

delay(i);

all_off();

nine_ones();

nine_tens();

delay(i);

all_off();

i = 1000; // Make this one second for count below

} //void setup

//**************************************

void loop() //Loop Forever

{

for (int display_count = 0; display_count <= 59; display_count++){

switch (display_count) { // branch (switch) to case below and display the two digits

case 0:

zero_tens();

zero_ones();

break;

case 1:

zero_tens();

one_ones();

break;

case 2:

zero_tens();

two_ones();

break;

case 3:

zero_tens();

three_ones();

break;

case 4:

zero_tens();

four_ones();

break;

case 5:

zero_tens();

five_ones();

break;

case 6:

zero_tens();

six_ones();

break;

case 7:

zero_tens();

seven_ones();

break;

case 8:

zero_tens();

eight_ones();

break;

case 9:

zero_tens();

nine_ones();

break;

case 10:

one_tens();

zero_ones();

break;

case 11:

one_tens();

one_ones();

break;

case 12:

one_tens();

two_ones();

break;

case 13:

one_tens();

three_ones();

break;

case 14:

one_tens();

four_ones();

break;

case 15:

one_tens();

five_ones();

break;

case 16:

one_tens();

six_ones();

break;

case 17:

one_tens();

seven_ones();

break;

case 18:

one_tens();

eight_ones();

break;

case 19:

one_tens();

nine_ones();

break;

case 20:

two_tens();

zero_ones();

break;

case 21:

two_tens();

one_ones();

break;

case 22:

two_tens();

two_ones();

break;

case 23:

two_tens();

three_ones();

break;

case 24:

two_tens();

four_ones();

break;

case 25:

two_tens();

five_ones();

break;

case 26:

two_tens();

six_ones();

break;

case 27:

two_tens();

seven_ones();

break;

case 28:

two_tens();

eight_ones();

break;

case 29:

two_tens();

nine_ones();

break;

case 30:

three_tens();

zero_ones();

break;

case 31:

three_tens();

one_ones();

break;

case 32:

three_tens();

two_ones();

break;

case 33:

three_tens();

three_ones();

break;

case 34:

three_tens();

four_ones();

break;

case 35:

three_tens();

five_ones();

break;

case 36:

three_tens();

six_ones();

break;

case 37:

three_tens();

seven_ones();

break;

case 38:

three_tens();

eight_ones();

break;

case 39:

three_tens();

nine_ones();

break;

case 40:

four_tens();

zero_ones();

break;

case 41:

four_tens();

one_ones();

break;

case 42:

four_tens();

two_ones();

break;

case 43:

four_tens();

three_ones();

break;

case 44:

four_tens();

four_ones();

break;

case 45:

four_tens();

five_ones();

break;

case 46:

four_tens();

six_ones();

break;

case 47:

four_tens();

seven_ones();

break;

case 48:

four_tens();

eight_ones();

break;

case 49:

four_tens();

nine_ones();

break;

case 50:

five_tens();

zero_ones();

break;

case 51:

five_tens();

one_ones();

break;

case 52:

five_tens();

two_ones();

break;

case 53:

five_tens();

three_ones();

break;

case 54:

five_tens();

four_ones();

break;

case 55:

five_tens();

five_ones();

break;

case 56:

five_tens();

six_ones();

break;

case 57:

five_tens();

seven_ones();

break;

case 58:

five_tens();

eight_ones();

break;

case 59:

five_tens();

nine_ones();

break;

} // case switch statement

delay(i); // i is set above to one second

all_off();

} // for display_count loop

} //void loop

// Function subroutines below to turn on and off the 7-segments

// "_ones" is for the ONES place in the counter. "_tens" is for TENS place in the counter

void zero_ones() {

// segments a b c d e

digitalWrite(a_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(c_ones, 0);

digitalWrite(d_ones, 0);

digitalWrite(e_ones, 0);

digitalWrite(f_ones, 0);

} //zero_ones

void one_ones() {

// segments b c

digitalWrite(b_ones, 0);

digitalWrite(c_ones, 0);

} //ones_ones

void two_ones() {

// segments a b g e d

digitalWrite(a_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(g_ones, 0);

digitalWrite(e_ones, 0);

digitalWrite(d_ones, 0);

} //two_ones

void three_ones() {

// segments a b g c d

digitalWrite(a_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(g_ones, 0);

digitalWrite(c_ones, 0);

digitalWrite(d_ones, 0);

} //three_ones

void four_ones() {

// segments f g b c

digitalWrite(f_ones, 0);

digitalWrite(g_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(c_ones, 0);

} //four_ones

void five_ones() {

// segments a f g c d

digitalWrite(a_ones, 0);

digitalWrite(f_ones, 0);

digitalWrite(g_ones, 0);

digitalWrite(c_ones, 0);

digitalWrite(d_ones, 0);

} //five_ones

void six_ones() {

// segments a f g c d e

digitalWrite(a_ones, 0);

digitalWrite(f_ones, 0);

digitalWrite(g_ones, 0);

digitalWrite(c_ones, 0);

digitalWrite(d_ones, 0);

digitalWrite(e_ones, 0);

} //six_ones

void seven_ones() {

// segments a b c

digitalWrite(a_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(c_ones, 0);

} //seven_ones

void eight_ones() {

// segments a b c d e f g

digitalWrite(a_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(c_ones, 0);

digitalWrite(d_ones, 0);

digitalWrite(e_ones, 0);

digitalWrite(f_ones, 0);

digitalWrite(g_ones, 0);

} //eight_ones

void nine_ones() {

// segments a b c d e f g

digitalWrite(a_ones, 0);

digitalWrite(b_ones, 0);

digitalWrite(c_ones, 0);

digitalWrite(d_ones, 0);

digitalWrite(f_ones, 0);

digitalWrite(g_ones, 0);

} //nine_ones

void zero_tens() {

// segments a b c d e

digitalWrite(a_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(c_tens, 0);

digitalWrite(d_tens, 0);

digitalWrite(e_tens, 0);

digitalWrite(f_tens, 0);

} //zero_tens

void one_tens() {

// segments b c

digitalWrite(b_tens, 0);

digitalWrite(c_tens, 0);

} //ones_tens

void two_tens() {

// segments a b g e d

digitalWrite(a_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(g_tens, 0);

digitalWrite(e_tens, 0);

digitalWrite(d_tens, 0);

} //two_tens

void three_tens() {

// segments a b g c d

digitalWrite(a_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(g_tens, 0);

digitalWrite(c_tens, 0);

digitalWrite(d_tens, 0);

} //three_tens

void four_tens() {

// segments f g b c

digitalWrite(f_tens, 0);

digitalWrite(g_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(c_tens, 0);

} //four_tens

void five_tens() {

// segments a f g c d

digitalWrite(a_tens, 0);

digitalWrite(f_tens, 0);

digitalWrite(g_tens, 0);

digitalWrite(c_tens, 0);

digitalWrite(d_tens, 0);

} //five_tens

void six_tens() {

// segments a f g c d e

digitalWrite(a_tens, 0);

digitalWrite(f_tens, 0);

digitalWrite(g_tens, 0);

digitalWrite(c_tens, 0);

digitalWrite(d_tens, 0);

digitalWrite(e_tens, 0);

} //six_tens

void seven_tens() {

// segments a b c

digitalWrite(a_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(c_tens, 0);

} //seven_tens

void eight_tens() {

// segments a b c d e f g

digitalWrite(a_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(c_tens, 0);

digitalWrite(d_tens, 0);

digitalWrite(e_tens, 0);

digitalWrite(f_tens, 0);

digitalWrite(g_tens, 0);

} //eight_tens

void nine_tens() {

// segments a b c d e f g

digitalWrite(a_tens, 0);

digitalWrite(b_tens, 0);

digitalWrite(c_tens, 0);

digitalWrite(d_tens, 0);

digitalWrite(f_tens, 0);

digitalWrite(g_tens, 0);

} //nine_tens

void all_off() {

digitalWrite(a_ones, 1);

digitalWrite(b_ones, 1);

digitalWrite(c_ones, 1);

digitalWrite(d_ones, 1);

digitalWrite(e_ones, 1);

digitalWrite(f_ones, 1);

digitalWrite(g_ones, 1);

digitalWrite(a_tens, 1);

digitalWrite(b_tens, 1);

digitalWrite(c_tens, 1);

digitalWrite(d_tens, 1);

digitalWrite(e_tens, 1);

digitalWrite(f_tens, 1);

digitalWrite(g_tens, 1);

} // all_off

-----

Thanks for the visit!