Question

In: Electrical Engineering

Design a clock display to show the time in hours, minutes, and seconds. Assume that we...

Design a clock display to show the time in hours, minutes, and seconds. Assume that we have a clock of exactly 1 KHz (1000 clock pulses per second). It will use 6 seven-segment displays and operate either in military time (hours 00 to 23) or regular time (1 to 12, with AM and PM). An input line, x, differentiates between the two. A seventh display is used to show A or P in the latter case; it is blank otherwise. Assume that there is a BCD-to-seven-segment decoder driver available; one is needed for each display other than the AM /PM one.

Solutions

Expert Solution

#include <Wire.h>
#include <DS3231.h>   
#define latchPin 5   
#define clockPin 6
#define dataPin 4
#define dot 2

DS3231 RTC;

int h;   
int m;
int thousands;   
int hundreds;
int tens;
int unit;

bool h24;
bool PM;

void setup ()
{
Wire.begin();
pinMode(9,OUTPUT);
pinMode(10,OUTPUT);
pinMode(11,OUTPUT);
pinMode(12,OUTPUT);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
pinMode(dot,OUTPUT);
}

void loop ()
{
digitalWrite(dot,HIGH);
int h= RTC.getHour(h24, PM);
int m = RTC.getMinute();   
int number = h*100+m;   
int thousands = number/1000;
int hundreds = number/100;
int tens = number/10;
int unit = number;   
int t= unit;
int u= tens;
int v= hundreds;
int w= thousands;


switch (t)
{
case 0:
unit = 63;
break;
case 1:
unit = 06;
break;
case 2:
unit =91;
break;
case 3:
unit=79;
break;
case 4:
unit=102;
break;
case 5:
unit = 109;
break;
case 6:
unit =125;
case 7:
unit = 07;
break;
case 8:
unit = 127;
break;
case 9:
unit =103;
break;
}

switch (u)
{
case 0:
tens = 63;
break;
case 1:
tens = 06;
break;
case 2:
tens =91;
break;
case 3:
tens=79;
break;
case 4:
tens=102;
break;
case 5:
tens= 109;
break;
case 6:
tens =125;
case 7:
tens = 07;
break;
case 8:
tens = 127;
break;
case 9:
tens =103;
break;
}

switch (v)
{
case 0:
hundreds = 63;
break;
case 1:
hundreds = 06;
break;
case 2:
hundreds =91;
break;
case 3:
hundreds=79;
break;
case 4:
hundreds=102;
break;
case 5:
hundreds = 109;
break;
case 6:
hundreds =125;
case 7:
hundreds = 07;
break;
case 8:
hundreds = 127;
break;
case 9:
hundreds =103;
break;
}
  
switch (w)
{
case 0:
thousands = 63;
break;
case 1:
thousands = 06;
break;
case 2:
thousands =91;
break;
case 3:
thousands=79;
break;
case 4:
thousands=102;
break;
case 5:
thousands = 109;
break;
case 6:
thousands =125;
case 7:
thousands = 07;
break;
case 8:
thousands= 127;
break;
case 9:
thousands =103;
break;
}

digitalWrite(9, LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST,thousands);
digitalWrite(latchPin, HIGH);   
digitalWrite(9, HIGH);
delay(5);

digitalWrite(10, LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST,hundreds );
digitalWrite(latchPin, HIGH);
digitalWrite(10, HIGH);
delay(5);   
  
digitalWrite(11, LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST,tens);
digitalWrite(latchPin, HIGH);
digitalWrite(11, HIGH);
delay(5);
  
digitalWrite(12, LOW);
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST,unit);   
digitalWrite(latchPin, HIGH);
digitalWrite(12, HIGH);
delay(5);
  
}


Related Solutions

Write a program that request a time interval in seconds and display it in hours, minutes,...
Write a program that request a time interval in seconds and display it in hours, minutes, second format. (java)
Using Quartus to design a stopwatch that can display tenths of seconds, minutes, and hours, with...
Using Quartus to design a stopwatch that can display tenths of seconds, minutes, and hours, with the gaps between HEX displays splitting the time units (i.e. minutes on HEX[5..4], hours on HEX[7..6]). Have the stopwatch cycle through 3 states of a state machine with a pushbutton. The 3 states are counter-clear, counter-start, and counter-stop
Write a C++ code that can convert time into hours, minutes, seconds. It can accept (seconds),...
Write a C++ code that can convert time into hours, minutes, seconds. It can accept (seconds), (minutes, seconds), (hours, minutes, seconds) The input can be written in main It should produce the following output: (67.4, 14, 5) is 67 Hours, 38 Minutes, 5 Seconds (127.86) is 0 Hours, 2 Minutes, 8 Seconds (-3, 73, 2) is -1 Hours, -46 Minutes, -58 Seconds
We want to design a simple "four clock pulse" timer circuit. In addition to the clock...
We want to design a simple "four clock pulse" timer circuit. In addition to the clock input, the timer has a "Restart" input (R), three "data" outputs (ABC) which indicate the count, and one "beeper" output (D). The behavior of the circuit is as follows: Idle Mode The timer output is ABC=100 and the beeper is off (D=0) as long as R=0. If R=1 on any clock edge in this mode, the timer goes into the... Restart/Hold Mode The timer...
Time Remaining 2 hours 2 minutes 11 seconds 02:02:11 Item 6 Item 6 Time Remaining 2...
Time Remaining 2 hours 2 minutes 11 seconds 02:02:11 Item 6 Item 6 Time Remaining 2 hours 2 minutes 11 seconds 02:02:11 The Molson Company had budgeted production for the year as follows: Quarter 1 2 3 4 Production in units 11,700 13,700 19,600 15,700 Four pounds of raw materials are required for each unit produced. Raw materials on hand at the start of the year total 5,700 lbs. The raw materials inventory at the end of each quarter should...
Time Remaining 3 hours 5 minutes 26 seconds 03:05:26 eBook Check my work Check My Work...
Time Remaining 3 hours 5 minutes 26 seconds 03:05:26 eBook Check my work Check My Work button is now disabled Item 3 Item 3 Time Remaining 3 hours 5 minutes 26 seconds 03:05:26 Polaski Company manufactures and sells a single product called a Ret. Operating at capacity, the company can produce and sell 38,000 Rets per year. Costs associated with this level of production and sales are given below: Unit Total Direct materials $ 20 $ 760,000 Direct labor 10...
Time Remaining 5 minutes 19 seconds 00:05:19 Item 23 Item 23 Time Remaining 5 minutes 19...
Time Remaining 5 minutes 19 seconds 00:05:19 Item 23 Item 23 Time Remaining 5 minutes 19 seconds 00:05:19 On April 1st, Bob the Builder entered into a contract of one-month duration to build a barn for Nolan. Bob is guaranteed to receive a base fee of $5,800 for his services in addition to a bonus depending on when the project is completed. Nolan created incentives for Bob to finish the barn as soon as he can without jeopardizing the structural...
Time Remaining 46 minutes 30 seconds 00:46:30 Item 7 Item 7 Time Remaining 46 minutes 30...
Time Remaining 46 minutes 30 seconds 00:46:30 Item 7 Item 7 Time Remaining 46 minutes 30 seconds 00:46:30 On Dec 31, 20X2, the end of the year, Schubert Co. had the following stockholders’ equity. You have been given the ending balances for the year and asked to compute the balances as of the beginning of the year. 9% Preferred Stock, $40 par $   600,000 Common Stock, $8 par $   960,000 Add’l PIC $1,355,000 Retained Earnings $1,255,000 Treasury Stock, 4,000 shares...
3. Design a digital watch that allows the user to set and display time.
3. Design a digital watch that allows the user to set and display time.
Write the definition for a generic / Template class called time that has hours and minutes...
Write the definition for a generic / Template class called time that has hours and minutes as structure. The class has the following member functions: SetTime to set the specified value in object ShowTime to display time object Sum to sum two time object & return time Write the definitions for each of the above member functions. Write main function to create three time objects. Set the value in two objects and call sum() to calculate sum and assign it...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT