Cov txheej txheem:

LCD IP/ Clock: 5 Kauj Ruam
LCD IP/ Clock: 5 Kauj Ruam

Video: LCD IP/ Clock: 5 Kauj Ruam

Video: LCD IP/ Clock: 5 Kauj Ruam
Video: LCD & OLED Display Comparison 2024, Hlis ntuj nqeg
Anonim
LCD IP/ Moos
LCD IP/ Moos
LCD IP/ Moos
LCD IP/ Moos

Cov lus qhia no yuav qhia koj yuav tsim lub LCD li cas uas qhia koj lub sijhawm tam sim no thiab tus IP/ tus tswv ntawm RPi.

Khoom siv

  1. Raspberry Pi
  2. SD daim npav nrog raspbian
  3. Kev Txuas WiFi
  4. Geek PI IIC/I2C 2004 2 Arduino UNO Raspberry Pi LCD zaub (20x4)
  5. 4x Poj niam rau poj niam jumper xov hlau
  6. Keyboard thiab nas

Kauj Ruam 1: Kauj Ruam 1: Txuas Hluav Taws Xob

  1. Txuas tus pin hauv av ntawm LCD mus rau tus pin hauv av ntawm RPi
  2. Txuas VCC tus pin ntawm LCD mus rau 5v tus pin ntawm RPi
  3. Txuas SDA tus pin ntawm LCD mus rau SDA 2 tus pin ntawm RPi
  4. Txuas tus SCL tus pin ntawm LCD mus rau SCL 3 tus pin ntawm RPi

Raws li qhia hauv cov duab

Kauj Ruam 2: Kauj Ruam 2: Cloning Git Repo

  1. Nkag mus rau RPI
  2. Qhib davhlau ya nyob twg
  3. Ntaus cov hauv qab no

sudo apt-tau hloov tshiab

sudo apt-tau hloov tshiab

git clone

sudo rov pib dua

Kauj Ruam 3: Kauj Ruam 3: Txhim Kho Python3

** Koj tuaj yeem hla cov theem no yog tias koj muaj PYTHON3 THIAB PYTHON3-PIP INSTALLED YUAV TSUM TAU **

Tsuas yog sau cov kab hauv qab no ntawm cov cai rau hauv lub davhlau ya nyob twg

sudo apt-tau nruab python3

sudo apt-tau nruab python3-pip sudo reboot sudo apt-tau hloov tshiab sudo apt-tau hloov tshiab tag nrho

Kauj Ruam 4: Kauj Ruam 4: Xeem Txoj Cai

Yog li koj tam sim no muaj txhua yam teeb tsa npaj los khiav. Yog li mus rau qhov chaw uas cov ntaub ntawv koj cloned yog thiab ntaus:

python3 demo_lcd.py

Txoj haujlwm no qhia tias LCD ua haujlwm. Tam sim no koj tuaj yeem khiav qhov demo tom ntej:

python3 demo_clock.py

Txoj haujlwm no ua haujlwm teeb tsa lub moos yooj yim. Lub sijhawm yuav tsum tshwm ntawm qhov screen thiab hloov pauv thaum lub sijhawm hloov pauv.

Kauj Ruam 5: Kauj Ruam 5: Txoj Cai

Cov kauj ruam no yuav qhia koj yuav ua li cas thiaj lis lub moos thiab IP program nab nab.

Txoj cai pib los ntawm kev xa tag nrho cov tsev qiv ntawv cuam tshuam.

ntshuam lcddriver

ntshuam sijhawm ntshuam lub sijhawm ntshuam ntshuam ntsaws ntsaws zaub = lcd.driver.lcd ()

Tam sim no koj tuaj yeem tau txais IP thiab lub npe host:

testIP = "8.8.8.8"

s = socket.socket (socket. AF_INET, socket. SOCK_DGRAM)

s.connect ((testIP, 0))

ipaddr = s.getsockname () [0]

host = socket.gethostname ()

Txoj cai no yuav tau txais IP los ntawm RPi thiab teeb nws li "ipaddr".

Tam sim no koj tuaj yeem tau txais cov ntawv los luam tawm:

text = str (input ("Text input:")) cov

Txoj cai no tau txais qee cov ntawv los ntawm tus neeg siv (koj yuav xav tau cov keyboard thiab tso saib qhov no). Tom ntej no koj tuaj yeem tso txhua yam rau cov zaub:

sim: luam tawm ("Sau kom pom") display.lcd_display_string (ntawv, 1) # Sau kab ntawv ntawm kab ntawv rau thawj kab ntawm cov zaub display.lcd_display_string (ipaddr, 3) display.lcd_display_string (host, 4) thaum muaj tseeb: display.lcd_display_string (str (datetime.datetime.now (). time ()), 2) # Sau tsuas yog lub sijhawm rau cov zaub # Qhov program ces loops yam tsis ncua (tuaj yeem ntxiv nrog lub sijhawm pw tsaug zog)

tshwj tsis yog KeyboardInterrupt: # Yog tias muaj KeyboardInterrupt (thaum koj nias ctrl+c), tawm ntawm qhov program thiab ntxuav cov ntawv luam ("Ntxuav!") display.lcd_clear ()

Ib feem ntawm txoj cai tso tawm txhua qhov kev hloov pauv mus rau LCD Zaub thiab ua kom lub sijhawm rov zoo li qub.

Pom zoo: