Advertisement
MrLunk

Metric Clock (10 hours per day).

Feb 1st, 2023 (edited)
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.25 KB | Source Code | 0 0
  1. """
  2. This code converts regular time (in hours, minutes, and seconds) to metric time
  3. (in metric hours, metric minutes, and metric seconds). Metric time uses a base 10
  4. system instead of the base 60 system used in regular time.
  5.  
  6. The code first gets the number of seconds past midnight using the utime.time()
  7. function. It then calculates the decimal hours by dividing the number of seconds
  8. by 3600 (the number of seconds in an hour). It then converts decimal hours to metric
  9. time by multiplying by 100000 and dividing by 24. This gives us the number of metric
  10. seconds since midnight.
  11.  
  12. The metric time is then broken down into metric hours, metric minutes, and metric
  13. seconds using integer division and modulus operations.
  14.  
  15. The code then prints out both the metric time and regular time using the print()
  16. function. It also includes a 96ms delay using the utime.sleep_ms() function to
  17. make sure the code doesn't execute too quickly.
  18.  
  19. Metric Time information: https://en.wikipedia.org/wiki/Metric_time
  20.  
  21. Metric time clock example: https://minkukel.com/en/clocks/metric-clock/ (not mine)
  22. """
  23.  
  24. # Micropython Script for Raspberry Pi Pico by: MrLunk
  25.  
  26. import utime
  27. import time
  28.  
  29. FULL CODE ------------------->>> https://github.com/mrlunk/Raspberry-Pi-Pico
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement