Cov txheej txheem:

Ib Tus Pin Keypad Raspberry Pi Siv Qhia: 9 Kauj Ruam
Ib Tus Pin Keypad Raspberry Pi Siv Qhia: 9 Kauj Ruam

Video: Ib Tus Pin Keypad Raspberry Pi Siv Qhia: 9 Kauj Ruam

Video: Ib Tus Pin Keypad Raspberry Pi Siv Qhia: 9 Kauj Ruam
Video: Начало → Изучайте английский → Освойте ВСЕ ОСНОВЫ АНГЛИЙСКОГО ЯЗЫКА, которые вам НУЖНО знать! 2024, Hlis ntuj nqeg
Anonim
Ib Tus Pin Keypad Raspberry Pi Siv Qhia
Ib Tus Pin Keypad Raspberry Pi Siv Qhia

DISCLAIMER: Qhov no yog kev qhia siv rau QHOV QHOV QHOV ZOO TSHAJ PLAWS ZOO TSHAJ PLAWS: Ib tus lej KEYPAD. Qhov no tsis yog DIY PROJECT. Yog tias koj xav ua tus thawj coj koj tus kheej, EAGLE FILES tuaj yeem nrhiav tau thaum kawg ntawm TUTORIAL

Dab tsi yog Ib Tus Pin Keypad?

Ib Tus Pin Keypad ua rau siv tus lej lej lej kom yooj yim dua thiab cia koj khaws koj cov ntawv I/O uas muaj nqi rau lwm lub hom phiaj. 16 lub pob matrix keypad feem ntau xav tau 8 lub tswv yim digital ntawm lub microcontroller lossis ib lub computer board. Cov neeg nyiam tshaj plaws Arduinos txwv koj tsuas yog 14 tus lej digital, yog li 16-lub pob keypad tso koj nrog tsuas yog 6 tus pin rau qhov seem ntawm koj txoj haujlwm. Cov peev txheej-qhov tsis txaus no yuav ua rau kev tsim tus nqi pauv pauv lossis tus nqi kim dua kev tswj hwm tus tswj. Qhov One Pin Keypad module tshem tawm qhov xav tau rau txhua qhov ntawm cov khoom siv digital no. Raws li nws lub npe cuam tshuam, Ib Tus Pin Keypad siv tsuas yog ib tus pin (cov lus sib piv sib xws) ntxiv rau GND thiab VCC kev sib txuas, yog li txuas koj lub xov tooj cua yog nrawm! Rau Raspberry Pi cov neeg siv (lub hom phiaj cov neeg mloog rau qhov kev qhia no) nws tseem xav tau ADS1115 analog rau digital hloov pauv, uas yog qhov yooj yim heev rau xaim. Ib Tus Pin Keypad Python Pob (suav nrog) kuj tseem yooj yim rau lub program xav tau los ua cov txheej txheem ntawm cov keyboard, txuag koj lub sijhawm thiab siv zog ntau dua.

Rau Arduino Siv Qhia, nyem qhov no.

Kauj Ruam 1: Sau tag nrho Txhua Qhov

Sau txhua Qhov!
Sau txhua Qhov!

Txhawm rau pib nrog koj Ib Tus Pin Keypad board, koj yuav xav tau:

  • Ib Tus Pin Keypad Board
  • Ib qho Arduino ntawm qee qhov tsw (Ib qho Arduino Nano tau siv hauv qhov no)
  • 3 M/F jumper cables,
  • 4 M/M LOSSIS 4 ntau M/F jumper cables, nyob ntawm seb hom headers nyob ntawm koj li Raspberry Pi
  • Lub 16 khawm membrane membrane keypad
  • Breadboard (Ib qho me me tiag yog siv ntawm no)
  • ADS1115 Module (los ntawm Adafruit lossis clone)
  • Raspberry Pi nrog kev txuas internet thiab Raspbian OS (Kuv siv Ncab)
  • Raspberry Pi Accessories (ib qho HDMI Cable, lub zog siv, dongles, saib, thiab lwm yam yog nyob ntawm qhov tsw ntawm koj li Raspberry Pi)

Kauj ruam 2: Txuas

Txuas!
Txuas!
Txuas!
Txuas!

Hlau Ib Tus Pin Keypad raws li daim duab Fritzing, daim duab lossis ob qho tib si, qhov twg koj xav tau.

Thov nco tseg: daim ntawv ntawm Fritzing daim duab sawv cev rau Ib Tus Pin Keypad (thiab cov ntawv luv GND VCC thiab AOUT xaiv tus pinouts ntawm One Pin Keypad board)

Kauj Ruam 3: Nthuav Tawm Pob Python

Python Pob Txhim Kho!
Python Pob Txhim Kho!
Python Pob Txhim Kho!
Python Pob Txhim Kho!

Qhib lub davhlau ya nyob twg qhov rai thiab ntaus cov lus txib hauv qab no:

sudo apt-tau hloov tshiab

ces

pip3 nruab Progetto-One-Pin-Keypad

txhawm rau txhim kho pob thiab nws cov kev xav tau tsim nyog

Kauj Ruam 4: Txhim Kho Cov Piv Txwv

Txhim Kho Cov Piv Txwv
Txhim Kho Cov Piv Txwv

Kuv tsim cov ntawv tais ceev tseg rau tsev rau qhov chaw cia khoom nyob hauv tsev/pi yog tias koj xav ua tib yam (nws yog qhov ua tau kiag li), khiav cov lus txib no:

mkdv dev

tom qab ntawd, txhawm rau nkag mus rau hauv daim nplaub tshev, ntaus:

cd devv

Thaum kawg, txhawm rau clone lub chaw cia khoom, nkag mus rau cov lus txib hauv qab no:

git clone

Kauj ruam 5: Pab kom I2C

Pab kom I2C
Pab kom I2C
Pab kom I2C
Pab kom I2C
Pab kom I2C
Pab kom I2C

ADS1115 ADC (Analog to Digital Converter) tso siab rau I2C (Inter-Integrated Circuit) raws tu qauv txhawm rau sib tham nrog Raspberry Pi, los ntawm lub neej ntawd I2C npav tsis taus, kom pab tau nws, ntaus:

sudo raspi-teeb tsa

uas yuav coj koj mus rau lub qhov rai teeb tsa xiav, los ntawm qhov ntawd, siv cov xub xub thiab tus yuam sij nkag, xaiv

  1. Kev xaiv cuam tshuam
  2. Kuv 2C
  3. Tom qab ntawd mus rau

Tswv yim: Xa mus rau cov duab saum toj no tuaj yeem pab me ntsis! Yog tias koj tseem nyam, tsis ntshai! Xa mus rau qhov ua tau zoo npaum li cas-los ntawm Sparkfun!

Kauj Ruam 6: Khiav Calibratethresholds

Khiav Calibratethresholds!
Khiav Calibratethresholds!

Nkag mus rau qhov chaw cia khoom yog tias koj tsis tau ua thiab mus rau cov piv txwv piv txwv siv cov lus txib no:

Tswv yim: ntaus 'cd Prog' ces ntaus Tab, nws yuav tsum ua kom tiav lub npe khaws cia!

cd Progetto_One_Pin_Keypad_Python_Package

ces ntaus:

cd piv txwv

tom ntej no, khiav qhov piv txwv calibratethresholds siv cov lus txib no:

nab hab sej 3 calibratethresholds

thiab ua raws cov lus qhia pom ntawm lub console txhawm rau ntsuas koj lub rooj tsavxwm. Tom qab ntsuas ntsuas taug kev los ntawm txhua lub nyees khawm, ntsuas tawm koj qhov txiaj ntsig zoo sib xws kom pom tias lawv ua haujlwm los ntawm nias qee lub nyees khawm thaum hais kom "Pib.", Yog tias qhov txiaj ntsig tshiab ua pov thawj tsis raug, siv Ctrl C los tua qhov program thiab khiav nws. dua.

Qhov piv txwv ntsuas yuav tsum muab rau koj 2 kab ntawm txoj cai koj yuav xav tau hauv qhov piv txwv tom ntej, nco ntsoov khaws lub console qhib thiab/lossis luam ob qho tib si!

Kauj ruam 7: Hloov kho thiab Tom qab ntawd Nyem Readkeypadwithtimeout

Hloov kho thiab Tom qab ntawd Khiav Readkeypadwithtimeout
Hloov kho thiab Tom qab ntawd Khiav Readkeypadwithtimeout
Hloov kho thiab Tom qab ntawd Khiav Readkeypadwithtimeout
Hloov kho thiab Tom qab ntawd Khiav Readkeypadwithtimeout
Hloov kho thiab Tom qab ntawd Khiav Readkeypadwithtimeout
Hloov kho thiab Tom qab ntawd Khiav Readkeypadwithtimeout

Tam sim no tias koj Ib Tus Pin Keypad tau ntsuas, nws yog lub sijhawm siv nws los siv. Thaum koj tuaj yeem ua qhov no los ntawm kab hais kom ua siv vi, Kuv tus kheej nyiam siv IDE zoo li IDLE.

Qhib IDLE li (koj yuav xav tau cov nab hab sej version 3) thiab hloov kho kab hauv qab no:

Nco ntsoov tias cov nqi sib piv uas koj tau theej? Hloov kab 13 (saib hauv qab) nrog cov tshiab calibrated analog qhov tseem ceeb.

# ex: my_thresholds = [ntsuas qhov tseem ceeb yuav nyob ntawm no]

yog hloov nrog qhov no:

my_thresholds = [225, 2116, 3904, 5200, 6300, 7350, 8450, 9325, 10000, 10750, 11500, 12100, 12550, 13100, 13800, 14250]

Tom ntej no, ntxiv kab kab ntawv txuas ntxiv mus tom qab kab 23, (saib hauv qab):

keypad.useCalibratedThresholds (my_thresholds)

tau ntxiv tom qab kab 23:

# ex: keypad.use_calibrated_thresholds (koj lub npe array)

ua kab 22 txog 24 zoo li qhov no thaum kawg:

# Yog tias ntsuas qhov ntsuas tau siv, siv_calibrated_thresholds hauv qab no:

# ex: keypad.use_calibrated_thresholds (koj lub npe array)

keypad.use_calibrated_thresholds (kuv_thresholds)

Tom qab ua tiav, khiav cov cai thiab sim nws los ntawm kev nias qee lub pob! Xav tias dawb los hloov qhov piv txwv piv rau koj cov haujlwm! Nco ntsoov tias read_keypad_with_timeout rov qab lub pob raug nias raws li tus lej thiab lub sijhawm tau teev tseg hauv vib nas this! Yog tias koj tsis xav kom ncua sijhawm siv lub keypad. NO_TIMEOUT tas li.

Kauj Ruam 8: Yuav Ua Li Cas Ib Tus Pin Keypad Ua Haujlwm

Yuav Ua Li Cas Ib Tus Pin Keypad Ua Haujlwm
Yuav Ua Li Cas Ib Tus Pin Keypad Ua Haujlwm
Yuav Ua Li Cas Ib Tus Pin Keypad Ua Haujlwm
Yuav Ua Li Cas Ib Tus Pin Keypad Ua Haujlwm

Ntau ntawm Ib Tus Pin Keypad tus qauv tsim tawm los ntawm Hari Wiguna qhov kev siv ntawm qhov faib hluav taws xob kom tau txais tus nqi sib piv rau txhua tus yuam sij hauv 16 tus lej tus lej. Ib Tus Pin Keypad tus tsim tseem zoo ib yam, nrog ob peb tweaks. Yog tias koj xav tau cov lus qhia zoo txog yuav ua li cas One Pin Keypad ua haujlwm, xav tias dawb los tshuaj xyuas Hari Wiguna qhov yees duab txaus ntawm no!

Kauj Ruam 9: Xaus

Xaus
Xaus

Hauv cov lus qhia no, peb tau hais qhia yuav pib li cas nrog koj Ib Tus Pin Keypad board. Tam sim no, qhov xav paub ntawm koj yuav xav tias vim li cas readKeypadInstantaneous piv txwv kos duab tsis tau siv, qhov laj thawj yog tias nws tsis muaj txiaj ntsig, vim tias lub pob yuav tsum tau nias thaum nws raug hu, readKeypadInstantaneous () muaj nuj nqi tau siv feem ntau los ua kom yooj yim. readKeypadWithTimeout () hauv lub tsev qiv ntawv. Yog tias nws ntes koj lub qhov muag xav kom coj nws mus rau qhov tig. Zoo siab Hacking!

Yog tias koj muaj lus nug, tawm tswv yim hauv qab no lossis email rau peb ntawm [email protected]. Txhua qhov zoo tshaj, Progetto Company P. S. Raws li tau cog lus tseg, txuas mus rau pawg thawj coj saib Eagle Files.

Pom zoo: