Cov txheej txheem:

Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips (Ntu 2): 8 Kauj Ruam
Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips (Ntu 2): 8 Kauj Ruam

Video: Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips (Ntu 2): 8 Kauj Ruam

Video: Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips (Ntu 2): 8 Kauj Ruam
Video: Get Started → Learn English → Master ALL the ENGLISH BASICS you NEED to know! 2024, Hlis ntuj nqeg
Anonim
Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips (Ntu 2)
Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips (Ntu 2)

Hloov tshiab ntawm Tsev Automation Siv Raspberry Pi Matrix Lub Suab thiab Snips. Hauv PWM no yog siv rau kev tswj hwm sab nraud LED's thiab Servo motor

Tag nrho cov ntsiab lus muab rau hauv ntu 1

www.instructables.com/id/Controlling-Light…

Kauj Ruam 1: Matrix Core & Matrix HAL Kev teeb tsa ntawm RPi

1. Ntxiv Matrix repository thiab qhov tseem ceeb.

curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt -key ntxiv -

ncha "deb https://apt.matrix.one/doc/apt-key.gpg $ (lsb_release -sc) lub ntsiab" | sudo tee /etc/apt/sources.list.d/matrixlabs.list

Matrix repository rau Matrix HAL

curl https://apt.matrix.one/doc/apt-key.gpg | sudo apt -key ntxiv -echo "deb https://apt.matrix.one/doc/apt-key.gpg $ (lsb_release -sc) lub ntsiab" | sudo tee /etc/apt/sources.list.d/matrixlabs.list

sudo apt-tau hloov tshiab

sudo apt-tau hloov tshiab

2. Nruab qhov Matrix Core pob khoom.

sudo apt-tau nruab matrixio-malos

sudo rov pib dua

Nruab lub pob MATRIX HAL.

sudo apt-tau nruab matrixio-creator-init libmatrixio-creator-hal libmatrixio-creator-hal-dev

Rov pib dua koj lub cuab yeej.

sudo rov pib dua

3. Txhawm rau nruab ZeroMQ

ncha "deb https://download.opensuse.org/repositories/network…./" | sudo tee /etc/apt/sources.list.d/zeromq.list

wget https://download.opensuse.org/repositories/networ… -O- | sudo apt-key ntxiv

4. JavaScript teeb tsa Tsim cov phiaj xwm phiaj xwm hauv cov npe hauv tsev ntawm RPi

cd ~/mkdir js-matrix-core-app (lub npe twg koj xav tau)

cd js-matrix-core-app

npm pib

5. Txhim kho npm Pob rau ZMQ thiab Cov Txheej Txheem Tsis Zoo

Txhawm rau teeb tsa ZMQ thiab MATRIX Protocol Buffers npm pob. Nco ntsoov tias koj nyob hauv cov npe uas koj tsim saum toj no (lub npe koj muab). Ntawm no kuv muab nws js-matrix-core-app. Qhov no tso cai rau koj los cuam tshuam nrog Matrix Core los ntawm Node.js.

npm nruab zeromq --save

npm nruab matrix-protos --save

Raws li kuv tab tom siv JavaScript, yog li siv PWM rau LEDs sab nraud Kuv siv Matrix lite lub tsev qiv ntawv. Txhawm rau nruab nws siv cov lus hais hauv qab no kom ntseeg tau tias koj nyob hauv tib phau ntawv uas peb tsim thaum txhim kho Matrix core.

npm nruab @matrix-io/matrix-lite --save

Kauj ruam 2: Snips App (hloov tshiab)

Snips App (hloov tshiab)
Snips App (hloov tshiab)
Snips App (hloov tshiab)
Snips App (hloov tshiab)
Snips App (hloov tshiab)
Snips App (hloov tshiab)

1. Tsim qhov qhib tshiab thiab muab nws lub npe rau txhua yam uas koj xav tau. Ntawm no kuv siv plaub qhov

  • hloov rau, tawm, qhib, thiab kaw lub xeev
  • chav rau chav sib txawv xws li chav pw, chav dej thiab lwm yam
  • ntaus ntawv rau cov khoom siv xws li lub teeb, kiv cua, qhov rooj thiab lwm yam
  • ci ntsa iab rau teeb ci ci ntawm lub teeb nyob hauv chav sib txawv.

2. Tom qab ntawd muab lub npe hom rau. Ntawm no kuv tab tom tsim kev cai qhov hom.

chav qhov

Muab lub npe twg los xij koj xav tau. Tom qab ntawd ntxiv qhov tseem ceeb "chav dej", "chav pw", "chav ua noj", thiab "chav loj" thiab lwm yam.

Rau qhov hloov pauv Muab txhua lub npe yam koj xav tau.

Tom qab ntawd ntxiv qhov txiaj ntsig qhov "rau", "tawm", "qhib", thiab "kaw".

Ntaus qhov

Muab lub npe twg los xij koj xav tau. Tom qab ntawd ntxiv qhov qhov tseem ceeb "teeb", "kiv cua", thiab "qhov rooj".

qhov ci ci

Muab lub npe twg los xij koj xav tau. Tom qab ntawd ntxiv qhov txiaj ntsig 75, 50, 25, 0

3. Kaw lub app, txhawm rau qhia qhov piv txwv kev cob qhia uas yog siv qhov twg

  • Nyem ob npaug rau Off thiab On thiab xaiv lub npe lub npe (hloov).
  • Nyem ob npaug rau ntawm lub npe chav thiab xaiv lub npe (chav).
  • Ob npaug nyem rau ntawm lub teeb, kiv cua thiab xaiv lub npe lub npe (ntaus ntawv).
  • Ob npaug nias rau qhov muaj nuj nqis (0, 25, 50) thiab xaiv lub npe (qhov ci).

Tom qab ntawd khaws nws thiab koj tuaj yeem sim nws hauv lub qhov rais muab sab xis ntawm nplooj ntawv.

4. Tom qab ntawd xa nws

Kauj Ruam 3: Yuav Tsum Npm Pob

Rau xa xa nruab pob ntawm pob

npm nruab nodemailer

Npm pob rau kev sib tham raws kev sib tham ob tog

npm nruab socket.io

Npm pob rau nthuav qhia

npm nruab express

Yog koj xav hnov cov lus. Koj tuaj yeem rub tawm pob ntawm no.

npm install hais

Ntxiv cov kab no hauv qhov program (piv txwv)

const hais = xav tau ('hais')

say.speak ('Lub teeb ci tau teeb tsa rau 75');

Kauj ruam 4: Webpage

Kuv tau ua nplooj ntawv los qhia cov cav (chav, khoom siv, lub xeev cov cuab yeej, tus nqi siv zog thiab hnub tim) thiab ntsuas ntsuas qhia tus nqi siv tam sim no kom kuv tuaj yeem paub cov lus txib twg kuv siv thaum tham nrog snips. Ua raws cov theem hauv qab no txhawm rau ua lub vev xaib.

Nco tseg - Koj tuaj yeem siv Node server lossis Apache server.

Hauv qhov haujlwm no kuv tab tom siv node server li Apache server qeeb thiab nws tsis tuaj yeem hloov kho cov ntaub ntawv kom raug.

Nco tseg - Yog tias koj siv cov lej muab rau hauv txoj haujlwm no kom ntseeg tau tias koj txhua cov ntaub ntawv nyob hauv cd/var/www/html phau ntawv teev npe lossis koj tuaj yeem hloov chaw nyob hauv txoj haujlwm.

Ua ntej, txhawm rau nruab Apache server siv cov lus txib (Tsis xav tau)

sudo apt-tau nruab apache2

Apache server tsis xav tau yog tias koj muaj node server lossis Node server Ua cov ntaub ntawv tsis muaj npe server.js, ntxiv cov program muab rau hauv cov haujlwm program thiab khaws nws.

Txhawm rau khiav server siv cov lus txib

node server.js

Tom ntej no, mus rau phau ntawv teev npe cd/var/www/html thiab ua ob daim nplaub tshev

1. Ua lub npe nplaub tshev js siv cov lus txib

mkd yus

cd js // mus rau phau ntawv teev npe

Hauv/var/www/html/js phau ntawv teev npe cov ntaub ntawv angular.min.js thiab muab cov ntaub ntawv los ntawm qhov txuas

Hauv tib phau ntawv teev npe ua lwm cov ntaub ntawv npe gauge.min.js thiab muab cov ntaub ntawv los ntawm kab ntawv txuas

Yuav tsum tau cov ntaub ntawv

2. Ua lub npe nplaub tshev jsonpage siv cov lus txib

mkdir jsonpage

cd json paj

Hauv jsonpage phau ntawv teev npe ua cov ntaub ntawv info.js. Ua kom nws khoob

Nco tseg:- Json cov ntaub ntawv yuav raug tshem tawm tom qab 50 lub suab hais kom ua

Kauj ruam 5: ID nkag mus nplooj ntawv

Txhawm rau ua nplooj ntawv nkag mus rau phau ntawv teev npe cd/var/www/html thiab ua cov ntaub ntawv khoob npe index.html. Ntxiv qhov program muab rau hauv qab no

Kauj Ruam 6: Nplooj Ntawv Tseem Ceeb

Txhawm rau ua nplooj ntawv tseem ceeb mus rau phau ntawv teev npe cd/var/www/html thiab ua cov ntaub ntawv tsis muaj npe HA.html (ib qho). Ntxiv qhov program muab rau hauv qab no

Rau kev ntsuas ntsuas ua qhov khoob cov ntaub ntawv npe index.js hauv cd/var/www/html phau ntawv teev npe. Txoj haujlwm tau muab rau hauv qab no.

Kauj ruam 7: Pab

assistant.js rau lub vev xaib raug muab hauv qab no

Thaum ua tiav nrog txhua qhov teeb tsa. Ntxiv mus, qhib lub plhaub thiab khiav

cd js-matrix-core-app

node pab.js

Qhib lwm lub plhaub thiab khiav

cd/var/www/html

node server.js

Qhib browser

localhost: 8080/index.html

Pom zoo: