Cov txheej txheem:

Relay Tswj Nrog Raspberry Pi: 3 Cov Kauj Ruam
Relay Tswj Nrog Raspberry Pi: 3 Cov Kauj Ruam

Video: Relay Tswj Nrog Raspberry Pi: 3 Cov Kauj Ruam

Video: Relay Tswj Nrog Raspberry Pi: 3 Cov Kauj Ruam
Video: Node-Red ep-06 การทำ Line chat bot โต้ตอบด้วย Message แบบต่างๆ 2024, Kaum ib hlis
Anonim
Relay Tswj Nrog Raspberry Pi
Relay Tswj Nrog Raspberry Pi

Peb txhua tus tau ntsib teeb meem thaum raspberry pi board tsis muaj peev xwm hloov pauv ntawm ntau yam khoom siv ib txhij. Yog li txuas ntau yam khoom siv siv 26 GPIO pins tsis tuaj yeem ua tau. Ntxiv mus, nws tsis tuaj yeem txuas ntxiv mus dhau 26 yog li ntau dua 26 lub cuab yeej tsis tuaj yeem txuas nrog.

Qhov teeb meem no tuaj yeem daws tau los ntawm kev siv GPIO lub taub hau. Ntawm ib lub taub hau, peb tuaj yeem txuas Lub Rooj Sib Tham Relay nrog txog 16 Relays thiab peb tuaj yeem txuas ntxiv suav cov laug cam rau 128. Yog li, tag nrho, 128*16 cov cuab yeej tuaj yeem txuas nrog.

Cia Peb Pib!

Kauj Ruam 1: Xav Tau Kho Vajtse

Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau
Kho vajtse xav tau

Rau qhov haujlwm no, peb yuav siv:

1. Tus Tswj Tus Kheej

2. Raspberry Pi

3. I2C ntaub thaiv npog

4. 12V Lub Hwj Chim Adapter

5. I2C Txuas Txuas Cable

Koj tuaj yeem yuav cov khoom los ntawm txhaj rau lawv. Tsis tas li, koj tuaj yeem pom cov khoom zoo ntxiv ntawm Dcube Store.

Kauj Ruam 2: Kev Sib Txuas Kho Vajtse

Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas
Kho vajtse sib txuas

Cov kauj ruam los txuas Raspberry Pi nrog I2C Shield/Adapter

Ua ntej, coj Raspberry Pi thiab tso I²C Shield rau nws. Nias lub Shield maj mam thiab peb tau ua tiav nrog cov kauj ruam no yooj yim li ncuav qab zib (saib daim duab #1 ).;

Kev sib txuas ntawm MCP23008 Tus Tswj Tus Kheej thiab Raspberry Pi

Siv tus I2C cable, txuas MCP23008 Txuas tus tswj mus rau Raspberry ntawm I2C txuas chaw nres nkoj ntawm I2C Shield (saib daim duab #3).

Hwj chim rau cov laug cam

Raspberry Pi tuaj yeem siv tau los ntawm ib qho Micro USB Cable. Nws ua haujlwm ntawm 5V thiab 2A. Txuas lub Micro USB cable rau hauv lub hwj chim nkaus ntawm Raspberry Pi. Tsis tas li, tsis txhob hnov qab tso lub hwj chim rau Tus Tswj Tus Kheej nrog 12V Lub Hwj Chim Adapter. Plug rau hauv thiab peb zoo mus!

Qhov kev sib txuas zaum kawg tau muab rau hauv daim duab #4.

Kauj Ruam 3: Ua Haujlwm thiab Code (Siv Java)

Peb tau khau raj lub cuab yeej nrog Linux (Raspbian). Hauv qhov no, peb tab tom siv Raspberry Pi nrog Monitor Screen

1. Nruab "pi4j library" los ntawm https://pi4j.com/install.html. Pi4j yog Java Lub Tsev Qiv Ntawv Tso Tawm/Tso Tawm rau Raspberry Pi. Ib txoj hauv kev yooj yim thiab nyiam tshaj plaws los teeb tsa "pi4j library" yog ua raws cov lus hais hauv qab no ncaj qha rau hauv koj li Raspberry Pi:

curl -s get.pi4j.com | sudo bash LOS YOG curl -s get.pi4j.com

2. Txhawm rau tsim cov ntawv tshiab uas yuav sau cov cai, cov lus txib hauv qab no yuav raug siv:

vi FILE_NAME.java

np. vi SAMPLE1.java

3. Tom qab tsim cov ntawv, peb tuaj yeem nkag mus rau tus lej hauv no. Qee qhov piv txwv java cov lej muaj nyob ntawm peb GitHub Cov Chaw Cia Khoom. Cov no tau npaj los siv yooj yim los ntawm kev luam lawv los ntawm no.

4. Txhawm rau ntxig tus lej nias "i".

5. Luam cov cai los ntawm cov chaw khaws khoom saum toj no thiab muab nws tso rau hauv cov ntawv uas koj tsim.

6. Nyem “esc” ib zaug ua tiav nrog cov cim.

7. Tom qab ntawv siv cov lus hais hauv qab no kom tawm ntawm lub qhov rai chaws:

wq: twg

Nov yog sau ntawv txiav txim kom rov qab los rau lub qhov rai qhov rai

8. Sau cov cai siv cov lus txib hauv qab no:

pi4j FILE_NAME.java

np. pi4j SAMPLE1.java

9. Yog tias tsis muaj qhov yuam kev, khiav qhov program siv cov lus hais hauv qab no:

pi4j FILE_NAME

Piv txwv pi4j SAMPLE1

Cov chaw cia khoom muaj 5 tus lej piv txwv thiab tuaj yeem tswj kev xa tawm hauv ntau qhov sib txawv ua ke. Yog li peb tau ua tiav Relay tswj nrog raspberry pi.

Cia peb pom lub suab twg koj tuaj yeem ua, kom ua las voos txuas ntxiv !!

Pom zoo: