Computers and modern gadgets

An electronic clock with a wide variety of functionalities is one of the most widely used electronic devices in everyday life, the control of which is built on the basis of a finite automaton model. Electronic watches usually show the time, date, allow you to set the time and date, and also perform many other functions (for example, they can be turned into a stopwatch with reset and stop of its readings, into an alarm clock, etc.). All these features are controlled by a built-in finite-automatic converter, the inputs of which are the events of pressing external control buttons. The block diagram of the electronic clock is shown in fig. 3.11. The control buttons are labeled “a” and “b” here. In addition to the display device that flashes the digits and the display circuit that converts the BCD codes of the digits into a seven-digit LED control code, the diagram shows four display registers that store the BCD codes of the four digits that are currently displayed on the dial using the circuit and device display, combinational circuits “OR”, passing any of the allowed codes to the display registers, the “Control” bus, allowing in each situation the output to the display registers of signals only of either a stopwatch, or a clock, or a date. The circuit also contains stopwatch registers and a tick generator that outputs a signal at a frequency of 1 Hz. The figure shows the moment “June 19, 15 hours 04 minutes, 43 seconds”.

Fig.3.11. Structural diagram of electronic clock

The control device, which organizes the work of all elements of the electronic clock, is built on the basis of the finite state machine model. The transition graph of this automaton is shown in Fig. 3.12. In the initial state, the time is displayed. This means that the binary code of this state (after decoding) opens the outputs of four BCD registers storing units and tens of minutes and units and tens of hours to the inputs of four combinational circuits “OR”.

Fig.3.12. Electronic clock control device

The state machine responds to the event of pressing the button “a” on the clock case by transitioning to the state “ Setting minutes”, in which the event of pressing the button “b” will cause an increase in the number stored in the registers reserved for minutes. In this case, transfers from the seconds register and to the register reserved for storing the number are blocked. Button press event “b” in state “ Set months” will cause an increase in the number stored in the registers allocated for the month. On fig. 3.12 does not show the possibility and algorithm of working with a stopwatch.

The industry produces many types of electronic watches with different functionalities. Control circuits for such clocks can be built with the skill of implementing finite functional converters and building finite-automatic models of discrete control systems.

Question: Task. Electronic clock based on simple arithmetic operations


Hello, forum users!
Help me with this problem please >_<
Task:
Electronic clocks show time in the h:mm:ss format, that is, first the number of hours is recorded, then the two-digit number of minutes is mandatory, then the two-digit number of seconds is mandatory. The number of minutes and seconds, if necessary, are padded to a two-digit number with zeros.

n seconds have passed since the beginning of the day. Output what the clock shows.
Input data
An integer n is entered.

Output
Output the answer to the problem, following the required format.

Examples
input data
3602
output
1:00:02

Here's what I got:

Java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 import ; import javax.swing.plaf.synth.SynthOptionPaneUI; import java.util.Scanner ; public class quest ( public static void main(String args) ( Scanner in = new Scanner (System .in ) ; long n,h,m,s; n = in.nextLong () ; h = (n % (3600 * 24 ) ) /3600 ;m = (n % 3600 ) / 60 ;s = (n % 60 ) ;if (m< 10 ) { if (s< 10 ) { System .out .println (h+ ":0" +m+ ":0" +s) ; } else if (s>10 ) ( System .out .println (h+ ":0" +m+ ":" +s) ; ) ) else if (m> 10 ) ( if (s< 10 ) { System .out .println (h+ ":" +m+ ":0" +s) ; } else if (s>10 ) ( System .out .println (h+ ":" +m+ ":" +s) ; ) ) ) )

This solution is not true in all cases, although I don't understand why =c
Help me find the problem, I will be grateful!

Answer:

Java
1 2 3 int i = 3602 ; LocalTime time = LocalTime.MIDNIGHT .plus (i, SECONDS) ; System .out .println (time) ;

Question: Digital alarm clock Delphi


Friends, it is necessary to protect the practice, they gave the task of an electronic clock with an alarm clock, who will help or throw off?)
I will be very, very grateful)

Added after 1 minute
friends, preferably with wording)

Answer:

Message from anegdot

Electronic clock turns out

Let's look at your watch and see what's wrong.


Input data

Output





Python
1 2 3 4 5 6 7 8 9 n = int (input () ) if n< 1440 : print (n//60 ) print (n%60 ) else : a = 1440 - n a *= -1 print (a//60 ) print (a%60 )

Answer: Can be solved without conditions:

Question: Electronic clock


It is necessary to develop a program that implements an electronic clock. The numbers are implemented graphically through a set of rectangles, and not in text form.
Required interface elements: Main menu bar, Shape elements, or using the Canvas property to draw numbers and a control button.

Answer: xxbesoxx, not so simple. Task

Message from Capetra

The numbers are implemented graphically through a set of rectangles, not in textual form.

Capetra,

P.S. if you carefully look at the topic, you will find a lot of interesting things

Question: Problem about electronic clock


Number n is given. N minutes have passed since the beginning of the day. Determine how many hours and minutes the digital clock will show at this moment.

Input data
Enter the number n - integer, positive, does not exceed 10 to the seventh power.

Output
The program should output two numbers: the number of hours (from 0 to 23) and the number of minutes (from 0 to 59).

Note that the number n can be greater than the number of minutes in a day.
__________________________________________________________________________________________
my solution, help me find the error.
___________________________________________________________________________________________

Python code
1 2 3 4 5 6 7 8 9 n = int (input () ) if n< 1440 : print (n//60 ) print (n%60 ) else : a = 1440 - n a *= -1 print (a//60 ) print (a%60 )

Answer:

Message from Andrey_Goa

Find out the number of days

Why is this? The number of days is not needed anywhere, only the remainder of the division

Python code
1 2 hours = (n % 1440 ) // 60 mins = (n % 1440 ) % 60

Question: "Electronic clock"


The task itself: "The electronic clock shows time in the h: mm: ss format, that is, first the number of hours is recorded, then the two-digit number of minutes is mandatory, then the two-digit number of seconds is mandatory. The number of minutes and seconds, if necessary, is padded to a two-digit number with zeros.
n seconds have passed since the beginning of the day. Print what the clock shows."
Link to it: .
Pascal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 Program Time2; var a, n: Integer ; Begin Readln(n) ; If n= 0 then Writeln ("00" , ":" , "00" , ":" , "00" ) else If (n<3600 ) and ((n div 60 ) <10 ) and ((n mod 60 ) <10 ) then Writeln ("00:0" , n div 60 , ":0" , n mod 60 ) else If (n<3600 ) and ((n div 60 ) >= 10 ) and ((n mod 60 ) >= 10 ) then Writeln ("00:" , n div 60 , ":" , n mod 60 ) else If (n<86400 ) and (n>3600 ) and ((n div 3600 )<10 ) and (((n mod 3600 ) div 60 ) <10 ) and (((n mod 3600 ) mod 60 ) <10 ) then Writeln ("0" , n div 3600 , ":0" , (n mod 3600 ) div 60 , ":0" , (n mod 3600 ) mod 60 ) else If (n<86400 ) and (n>3600 ) and ((n div 3600 ) >= 10 ) and (((n mod 3600 ) div 60 ) >= 10 ) and (((n mod 3600 ) mod 60 ) >10 ) then Writeln (n div 3600 , " :" , (n mod 3600 ) div 60 , ":" , (n mod 3600 ) mod 60 ) else If (n mod 86400 = 0 ) then Writeln ("00" , ":" , "00" , ":" , "00" ) else a: = n mod 86400 ; If (n>86400 ) and ((a div 3600 ) >= 10 ) and (((a mod 3600 ) div 60 ) >= 10 ) and (((a mod 3600 ) mod 60 ) >= 10 ) then Begin ( a:=n mod 86400;) Writeln (a div 3600 , ":" , (a mod 3600 ) div 60 , ":" , (a mod 3600 ) mod 60 ) end else If (n>86400 ) and ((a div 3600 )<10 ) and (((a mod 3600 ) div 60 ) <10 ) and (((a mod 3600 ) mod 60 ) <10 ) then Writeln ("0" , a div 3600 , ":0" , (a mod 3600 ) div 60 , ":0" , (a mod 3600 ) mod 60 ) end .

The problem is that until I started trying to make it output in the "correct" format, everything was fine. It gave out for any given number, tested 30 options. I began to suffer with these zeros, which should appear before minutes or seconds, if there are less than 10 of them and everything went to hell. Now the program works correctly only for certain numbers, and I have not yet been able to catch the "trigger" algorithm. On most numbers, the program simply does not produce anything. It would be nice to at least give some errors, but no, just a blank screen.
Does this method of "correct" writing through "If" have the right to life at all?
Here is the original version, where everything was issued in the wrong format, but essentially correct

Pascal
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Program Time2; var a, n: Integer ; Begin Readln(n) ; If n= 0 then Writeln ("00" , ":" , "00" , ":" , "00" ) else If n<86400 then Writeln (n div 3600 , ":" , (n mod 3600 ) div 60 , ":" , (n mod 3600 ) mod 60 ) else If n mod 86400 = 0 then Writeln ("00" , ":" , "00" , ":" , "00" ) else If n>86400 then Begin a: = n mod 86400 ; Writeln (a div 3600 , ":" , (a mod 3600 ) div 60 , ":" , (a mod 3600 ) mod 60 ) ; end end .

And in what case is the program generally "just silent"?

Answer:

Pascal
1 2 3 4 5 6 7 8 9 10 11 12 varn: Longint ; h, m, s: Integer ; begin ReadLn(n) ; h:=n div 3600 mod 24 ; m:=n mod 3600 div 60 ; s:=n mod 3600 mod 60 ; Write (h, ":" ) ; if m<10 then Write ("0" ) ; Write (m, ":" ) ; if s<10 then Write ("0" ) ; WriteLn (s) ; end .

Clue: Digital alarm clock


Hi people! Please help me to solve the problem. There are electronic clocks that show real time. You need to place 3 buttons on the form: "H", "M", "A". Button
“H” (Hours) increases the number of hours by one, and the “M” (Minutes) button increases the number of minutes. The increase occurs modulo 24 and 60, respectively. Such a clock has a simple behavior, since each of the two input actions (pressing the first or second button) leads to a single, in advance
a certain reaction of the clock. Additional button "A" (Alarm) is designed in them to turn the alarm on and off. If the alarm clock is off, then the "A" button turns it on and puts the clock in the mode, in
in which the "H" and "M" buttons set not the current time, but the response time
alarm clock. Pressing button "A" again returns the watch to normal mode. Moreover, all this should be done using automatic programming. Here is the project:
But the teacher gave a listing of the program, but only in C++. Please help if anyone has done something similar. Maybe it can be modified somehow.
C++
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 classAlarm_Clock( public : voidh_button() //H button press( if (is_in_alarm_time_mode) ( alarm_hours= (alarm_hours+ 1 ) % 24 ; ) else ( hours= (hours+ 1 ) % 24 ; ) ) voidm_button() //Press the button M ( if (is_in_alarm_time_mode) ( alarm_minutes= (alarm_minutes+ 1 ) % 60 ; ) else ( minutes= (minutes+ 1 ) % 60 ; ) ) voida_button() // Press button A( if (is_alarm_on) ( if (is_in_alarm_time_mode) ( is_in_alarm_time_mode= false ; ) else ( bell_off() ; is_alarm_on= false ; ) ) else ( is_alarm_on= true ; is_in_alarm_time_mode= true ; ) ) voidtick() //Activation of the minute timer( if (is_alarm_on&&! is_in_alarm_time_mode) { if(( minutes == alarm_minutes1 ) && ( hours == alarm_hours ) || ( alarm_minutes == 0 ) && ( minutes == 59 ) && ( hours == alarm_hours1 ) ) bell_on () ; elseif (( minutes == alarm_minutes ) && ( hours == alarm_hours ) ) bell_off () ; } minutes = ( minutes + 1 ) % 60 ; if( minutes == 0 ) hours = ( hours + 1 ) % 24 ; } private: intours ; //Current time clock intminutes ; //Minutes of the current time intalarm_hours ; //Hours of the alarm intalarm_minutes ; //Minutes of the alarm boolis_alarm_on ; //Is the alarm enabled? boolis_in_alarm_time_mode ; //Is the alarm time setting mode active? voidbell_on () { ...} //Enable call voidbell_off () { ...} // Turn off the call } ;

I fixed the electronic clock. This is unrealistically cool, considering that I have never been an electronics engineer. This is the first time in my life. The breakdown was that they began to turn off at the time of the alarm. I thought that the air conditioner had lost its air conditioning. Despite the move, I still have air conditioners, soldered from some old board. The legs were correspondingly very short. Attached wires. Soldered in parallel to the old one and it worked. It is interesting that there was a place on the board just for one more air conditioner.

General form:

But the green barrel - I soldered it:

Works great.

For one, I decided to experiment. I recently learned about dynamic indicators. This means that the luminous indicators of many devices do not burn constantly all the time, but blink continuously, because it is cheaper, less wires. (This does not apply to liquid crystals. They do not burn at all, they are filters, but the light bulb under them glows.) I wonder how this affects the nervous system ... To check, you can take pictures of some scoreboard at a short shutter speed several times and there all the fluff will be visible. On this watch, already at 1/150 shutter speed, it became visible.





If anyone did not understand: I shot a perfectly serviceable watch. No matter how closely you look, it is impossible to see any flicker with the naked eye. We set the shutter speed to 1/25 - everything becomes normal:

And the eyes look good too. This is how indicators fool us. All.

Probably no device is so subject to all sorts of changes and unusual incarnations as an ordinary watch. Starting with solar and ending with atomic ones - and how many various variations between them ... Periodically laying out especially interesting schemes and designs from foreign sources, and this time we will introduce you to another device for showing the current time, which is not only on the old domestic vacuum indicator, so also just one digit.

Clock scheme with one digit

This watch uses the PIC16F84A microcontroller. The circuit is quite simple as it uses a single transistor driven indicator and does not require an overly powerful power converter.

The lamp that I used in them is the Soviet IN-12A. The high supply voltage is obtained from components from a cheap digital camera (non-working), so it costs almost nothing.

The clock displays the time in such a way that periodically the indicator digits change from tens of hours to minutes. Then they go off for a few seconds. For example, to show the time 12:45 , will first light up for a second 1 , Then 2 , Then 4 , Then 5 . And a few seconds pause.

To set the time, you must press the button, and then the number you want to change will increase each time you press and so on in a circle from 0 to 9.

The main board contains all components except for the high voltage power conversion module. All files of boards, firmware, and so on, are in the general archive. Components required for the circuit:

  • Indicator IN-12
  • MK PIC16F84A
  • 10x high voltage SMD transistors MMBTA42
  • 13x 0805 resistors
  • Quartz 4 MHz
  • 2x capacitors 22pF
  • Button

The high voltage converter, as mentioned above, uses components taken from a camera flash - a transformer, a diode, and an output capacitor.

If you decide to assemble this watch, remember that it uses high voltage - up to 400 V. Be careful when assembling and operating!

To program code into a PIC, you will need a programmer and software for it. The Chinese programmer k150 was used here. It is necessary to load the .hex file into the program, and burn the MK chip.

Before the first clock was invented, people measured time by following the sun. In the morning, the sun rises above the horizon on one side, then crosses the sky to the opposite side and sets below the horizon. The next morning the same thing happens.

The time it takes for the sun to complete one revolution is called day. Days turn into weeks. Weeks to months. Months to years. Years to centuries.

One century is 100 years.

One year has 12 months.

In one month - 30 or 31 days (days).

Over time, the day was divided into two parts before noon and after noon. Each part was divided into 12 parts - hours. Therefore, the clock has 12 divisions. There are only 24 hours in a day.

Let's look at the clock. Bold dashes and numbers here indicate the hours, there are 12 of them on the clock. A small hand points to the clock. During the day, the small hand makes two revolutions of 12 hours. Slowly the little hand moves from hour to hour.

The hour is divided into 60 parts - minutes. So there are 60 minutes in 1 hour.

The clock face is divided into 60 parts (one division - one minute). The large hand points to the minutes. When the big hand makes one revolution, an hour passes and the small hand advances 1 hour.

The countdown starts from the mark 12. At midnight - 0 hours 0 minutes or 12 am.

When the small hand makes a complete revolution, 12 hours will pass and it will be 12 hours - noon.

On an electronic clock, the time is displayed in numbers, for example, 1 a.m. will be displayed like this:

AM (lat. ante meridiem - before noon), means that the displayed time is between midnight and noon or from 0 to 12 hours.

After 12 hours, the countdown continues. An hour later it will be 13 o'clock or 1 o'clock in the afternoon, then 14 (or 2 o'clock in the afternoon):

PM (lat. post meridiem - after noon) - the displayed time is between noon and midnight, that is, from 12 noon to 12 night or from 12 to 24 hours

The minute hand describes a circle in one hour. One division - 1 minute. When the minute hand points to 1 it's 5 minutes, 2 is 10 minutes, 3 is 15 minutes, and so on until the minute hand completes a full circle and returns to 12 to 60 minutes:

Let's make a table of hours during the day:

00:00AM

01:00 am

02:00 am

03:00AM

04:00AM

05:00AM

06:00AM

07:00AM

08:00AM

09:00AM

10:00 am

11:00 am

12:00PM

01:00PM

02:00PM

03:00PM

04:00PM

If you notice an error, select a piece of text and press Ctrl + Enter
SHARE:
Computers and modern gadgets