## Introduction: How to Make a Software Clock

To explore the Arduino world I have, when buying the base Board, also purchased a multi-shield for an amount of just over € 7.00.

On this shield there are a number of options including a 4 digit display and 3 buttons, witch I first used to make a software clock.

Apart from the digits and the buttons I later have used the LEDs, the buzzerd and the potentiometer:

The LEDs to give a ¼ minute signal.

The buzzerd to generate an hourly chime.

The potentiometer to the evil time:

-turning clockwise is faster

-turning against the clock is slower

## Step 1: The Program:

By perusing a concise manual and looking at examples (here and there) I came to the following program:

(sorry i don't know how how to get this in a nice window)

/* Learning how to programming Arduino */

/* by Rob van Staalduinen - Netherlands */

byte num[]={192,249,164,176,153,146,130,248,128,144,64,121,36,48,25,18,2,120,0,16};

// array with numbers 0-9 and 0.-9. (for hour digit [1])

byte time[]={0,0,0,0}; // array for putting the time in

byte push; // button-push delay counter

void setup ()

{ for (byte a=3;a<=13;a++) // sets datapins 4 to 13 to OUTPUT

{ pinMode(a,OUTPUT);} // 3=buzzer 4=latch 7=clk 8=data 10-13=leds

digitalWrite(3,HIGH);} // stops the buzzerd from beeping

void loop()

{ long speed = 37500+(1024-analogRead(0))*2; // time counter; changes time-speed for

// differend boards use potmeter on shield

for (byte c=10;c<=13;c++) // leds loop

{ digitalWrite(c,HIGH);} // sets seconds-led [c] to off

For (long a=0;a<=speed;a++) // delay timer

{ time[1]=time[1]+(!push);push=60;} // adds 1 to hours

{ time[2]=time[2]+(!push);push=60;} // adds 10 to minutes

{ time[3]=time[3]+(!push);push=60;} // adds 1 to minutes

push=push-(push>0); // down-counter for button-push

if (time[3]>9) {time[3]=0;time[2]=time[2]+1;} // sets minutes + 10 if over 9 and go to 0

if (time[2]>5) {time[2]=0;time[1]=time[1]+1;} // sets hours +1 if over 5 and go to 0

if (time[1]>9) {time[1]=0;time[0]=time[0]+1;} // sets hours + 10 if over 9 and go to 0

if ((time[0]>1)&&(time[1]>3)) {time[1]=0;time[0]=0; // sets hours to 0 if higher than 23

digitalWrite(3,LOW); delay(30);digitalWrite(3,HIGH);} // beeps every hour

for (char b=0;b<=3;b++) // loop for writing 4 digits

{ digitalWrite(4,LOW); // disable outputs

shiftOut(8,7, MSBFIRST,(num[time[b]+10*(b==1)])); // writes number-data

shiftOut(8,7, MSBFIRST,(241+(b==1)+3*(b==2)+7*(b==3))); // writes digit-data

digitalWrite(4,HIGH);} // send data to outputs

digitalWrite(a/(speed/4)+10,LOW);} // sets 15 seconds led

time[3]=time[3]+1;} // adds 1 minute to time

## Step 2: The Shield

I can recommend the shield for beginners because it has except the above mentioned functions also various other connectivity options such as blue-tooth, voice recognition, infrared, variable resistor and various other connections for just about everything available for additional options.

The shield I found you can see with the following link:

http://www.banggood.com/4-Digital-Multi-function-S...

There are also hundreds of other issues to find, a couple of them I already ordered.

Hopefully the program gives some look on the possibilities that Arduino programming offers and have I helped some people with this search a little further with their hobby.

Writing a program in as few bytes as possible I actually find even more fun than soldering.

Best regards,

Rob van Staalduinen

## Step 3: Extra Information

Multi function shield connection pins (for programming):

Analog:

0 – Pot

1 – Button 1 - jumper2 to -

2 – Button 2 - jumper2 to -

3 – Button 3 - jumper2 to -

4 – LM35 – jumper1 to +

5 – Shield connector 4

Digital:

00 – Bluethooth

01 – Bluethooth

02 – IR

03 – Buzzer

04 – Display - load / latch

05 – Shield connector 1

06 – Shield connector 2

07 – Display - clk

08 – Display - datain

09 – Shield connector 3

10 – Led 4

11 – Led 3

12 – Led 2

13 – Led 1