Useful algorithms

Automatic adjustment of the accuracy of the clock

The accuracy of the clock can be significantly improved if automatic time adjustments are made at certain time intervals.

				
					if (mm2 < 3) {
    JD2 = int((gg2 - 1) * 365.25) + int((mm2 + 12) * 30.6 + (float)0.7) + dd2;
  }
  else {
    JD2 = int(gg2 * 365.25) + int(mm2 * 30.6 + (float)0.7) + dd2;
  }
				
			

Setting the date and time of the clock

One of the necessary functions of the clock on Arduino is the ability for the user to set the date and time. We organize the control of this function by means of an encoder.

Automatic change of the brightness of the clock display depending on the illumination

One of the functions useful for the clock user is the automatic change of the display brightness. When there is a high level of illumination in the room where the clock is used, the brightness of the clock display automatically increases. When the light level is low, the brightness of the clock display automatically decreases. Thanks to this function, the clock will not blind your eyes in the evening and early in the morning, in a darkened room. And also will not annoy the inability to recognize the readings of the current time in a brightly lit room.

Calculating the day of the week by a given date

In devices where the user needs to set the date manually, you can use automatic calculation of the day of the week. This will optimize the time spent by the user on setting up the device.

Яндекс.Метрика