Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to DIY Electronic clock by python

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "python how to DIY electronic clock", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "python how to DIY the electronic clock".

1. Experimental purpose

1. Learn to extend the simple Icano in PC system. The method of the interface.

two。 What is the SPI interface.

3. Learn the usage of TPYBoard I2C interface.

4. Learn the method of LCD5110 wiring.

5. Sets the clock and displays the current time on the LCD5110.

two。 Required components

One DS3231 module

TPYBoard board

One LCD5110 display screen

A data line

Some DuPont lines

SPI interface of 3.TPYBoard

LCD5110 needs SPI interface to connect with TPYBoard to transmit data. SPI interface is synchronous serial data transmission between CPU and peripheral low-speed devices. TPYBoard has two SPI interfaces, and we use SPI1 interface.

I2C Interface of 4.TPYBoard

DS3231 communicates with TPYboard through I2C interface. DS3231 communicates with TPYBoard through this interface for data transmission. TPYBoard has two I2C interfaces, and we use I2C interface 1 here.

Wiring method of 5.DS3231

DS will let us use only four pins of DS3231's SCL,SDA,VCC,GND to set the current reading time. We use bit I2C interface 1, that is, DS3231's pin SCL connects with TPYboard's pin X9, and SDA connects with TPYBoard's pin X10.

6. Control 5110 display screen to display 6x8 characters

Let's take a look at the meaning of LCD5110 stitches (note: LCD5110 stitches are a little different)

The pins of TPYBoard correspond to the pins of 5110 as follows:

TPYBoard LCD5110 memo

-

# any Pin = > RST Reset pin (0=reset, 1=normal)

# any Pin = > CE Chip Enable (0=listen for input, 1=ignore input)

# any Pin = > DC Data/Command (0=commands, 1=data)

# MOSI = > DIN data flow (Master out, Slave in)

# SCK = > CLK SPI clock

# 3V3 or any Pin = > VCC 3.3V logic voltage (0=off, 1=on)

# any Pin = > LIGHT Light (0=on, 1=off)

# GND = > GND

If you still don't understand, just put the pin number on it.

TPYBoard LCD5110 memo

-

Y10 = > RST Reset pin (0=reset, 1=normal)

Y11 = > CE Chip Enable (0=listen for input, 1=ignore input)

Y9 = > DC Data/Command (0=commands, 1=data)

X8 = > DIN data flow (Master out, Slave in)

X6 = > CLK SPI clock

VCC

Y12 = > LIGHT Light (0=on, 1=off)

GND

7. source code

After wiring ok, and import font.py file, upcd8544.py file and DS3231.py, write main.py to set time, run main.py to display the current time on the 5110 display screen.

# main.py-- put your code hereafter imports pybimport upcd8544from machine import SPI,Pinfrom DS3231 import DS3231ds=DS3231 (1) ds.DATE ([16pr 11 DIN= 26]) ds.TIME ([16 pas 14 pas 6]) while True: ds.TEMP () ds.DATE () SPI = pyb.SPI (1) # DIN= > X8 Muir Mosiplash CLK = > X6-SCK # DIN= > SPI (1). MOSI'X8 'data flow (Master out) Slave in) # CLK = > SPI (1). SCK 'X6' SPI clock RST = pyb.Pin (' X1') CE = pyb.Pin ('X2') DC = pyb.Pin (' X3') LIGHT = pyb.Pin ('X4') lcd_5110 = upcd8544.PCD8544 (SPI, RST, CE, DC, LIGHT) lcd_5110.lcd_write_string (' Date',0,0) lcd_5110.lcd_write_string (str (ds.DATE ()) 0ds.TEMP 1) lcd_5110.lcd_write_string ('Time',0,2) lcd_5110.lcd_write_string (str (ds.TIME ()), 0pime 3) lcd_5110.lcd_write_string (' Tem',0,4) lcd_5110.lcd_write_string (str (ds.TEMP ()), 0Jing 5) pyb.delay (1000) so far I believe that everyone has a deeper understanding of "python how to DIY electronic clock", might as well come to the actual operation! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report