Cov txheej txheem:

Txuas Koj Arduino rau Cov Kev Pab Sab Nraud: 6 Cov Kauj Ruam
Txuas Koj Arduino rau Cov Kev Pab Sab Nraud: 6 Cov Kauj Ruam

Video: Txuas Koj Arduino rau Cov Kev Pab Sab Nraud: 6 Cov Kauj Ruam

Video: Txuas Koj Arduino rau Cov Kev Pab Sab Nraud: 6 Cov Kauj Ruam
Video: ๐Ÿคž8 YAM COV NEEG TXAWJ NTSE ZAM TSIS UA YOG DAB TSI?๐Ÿšซ 2024, Kaum ib hlis
Anonim
Txuas Koj Arduino rau Cov Kev Pab Sab Nraud
Txuas Koj Arduino rau Cov Kev Pab Sab Nraud

Nyob zoo! Cov ntawv qhia no yuav qhia koj yuav ua li cas txuas koj txuas nrog Arduino lossis IOT cov cuab yeej xaiv mus rau lwm qhov kev pabcuam. Txog rau qhov kev qhia no, peb yuav ua haujlwm nrog Qhov rai Yooj Yim (qhov tseeb tab sis tuaj yeem ua haujlwm tau zoo qhov rai), Yog Qhov No Yog Li No Thiab Adafruit IO.

Peb yuav siv Yog Yog Li No Los Yog (IFTTT txij tam sim no mus) los qhib peb Cov Qhov Rooj Qhov rai yooj yim thaum nws tshav ntuj sab nraum.

Kauj ruam 1: Yuav tsum tau ua

Yuav tsum muaj
Yuav tsum muaj

Cov ntawv qhia no cia siab tias koj twb paub yuav txuas koj li Arduino board rau Adafruit thiab teeb tsa pub. Yog tias koj xav tau kev ceeb toom sai yuav ua li cas, koj tuaj yeem ua raws qhov kev qhia no (ua lus Dutch).

- Koj pawg Arduino xaiv. Nws yuav tsum tau qhib WiFi.

- Ib lub micro USB cable

- Lub khoos phis tawj nrog Arduino IDE teeb tsa

- Tus as khauj ntawm Adafruit IO (kos npe txuas)

- Tus lej ntawm Yog Yog Qhov No Yog Li No (kos npe txuas)

Kauj Ruam 2: Teeb Koj Li Adafruit IO Pub

Teeb Koj Li Adafruit IO Pub
Teeb Koj Li Adafruit IO Pub

Cia peb teeb tsa Adafruit IO pub peb yuav xav xa peb cov ntaub ntawv mus rau:

  1. Nkag mus rau Adafruit IO thiab nyem rau ntawm "Pub" hauv cov ntawv qhia zaub mov bar nyob rau sab saud.
  2. Nyem rau ntawm "Ua", tom qab ntawd "Tsim Khoom Noj Tshiab". Peb yuav sau nws lub npe "WindowCurtains", tab sis koj tuaj yeem sau nws txhua txoj hauv kev uas koj nyiam.
  3. Nyem rau ntawm "Tsim" thiab koj ua tiav!

Kauj Ruam 3: Teeb tsa Yog Yog Qhov No Ces Tus Applet

Teeb Qhov Yog Yog Qhov No Ces Tus Applet
Teeb Qhov Yog Yog Qhov No Ces Tus Applet
Teeb Qhov Yog Yog Qhov No Ces Tus Applet
Teeb Qhov Yog Yog Qhov No Ces Tus Applet
Teeb Qhov Yog Yog Qhov No Ces Tus Applet
Teeb Qhov Yog Yog Qhov No Ces Tus Applet

Peb yuav siv IFTTT los qhib peb lub qhov rai yooj yim thaum nws tau tshav ntuj sab nraum. Hauv theem no, peb yuav xaiv qhov ua rau muaj mob thiab txuas nws mus rau Adafruit IO txhawm rau xa cov ntaub ntawv rau peb WindowCurtains pub.

Thaum koj muaj koj tus lej IFTTT npaj, koj tuaj yeem ua koj thawj applet.

  1. Ntawm IFTTT lub vev xaib, mus rau lub kaum sab xis saum toj thiab nyem rau ntawm koj lub npe siv, tom qab ntawd xaiv "Applet tshiab".
  2. Tam sim no peb yuav tsum xaiv peb qhov ntsuas. Nyem rau ntawm qhov tseem ceeb "+qhov no" khawm thiab tshawb rau Huab Cua Hauv Qab, tom qab ntawd xaiv qhov kev pabcuam.
  3. Saib rau "Cov xwm txheej tam sim no hloov mus rau" pobzeb, xaiv nws thiab xaiv "meej" los ntawm cov ntawv qhia zaub mov nco-down.

Nrog peb qhov teeb tsa teeb tsa, tam sim no peb tuaj yeem xaiv peb cov haujlwm pabcuam.

  1. Tshawb nrhiav Adafruit thiab xaiv qhov kev pabcuam.
  2. Xaiv "Xa cov ntaub ntawv mus rau Adafruit IO".
  3. Xaiv cov khoom noj uas koj xav xa cov ntaub ntawv rau. Qhov no yuav tsum yog qhov koj tau tsim hauv qib dhau los.
  4. Hauv qhov "Cov ntaub ntawv khaws tseg" teb, ntaus "Qhib". Nov yog cov ntaub ntawv uas yuav xa mus rau Adafruit pub.
  5. Nyem rau ntawm "Tsim kev nqis tes ua", tshuaj xyuas koj cov xwm txheej ntawm lub vijtsam tom ntej thiab nyem "Ua tiav" yog tias koj ua tiav.

Kauj Ruam 4: Txuas Peb Cov Khoom Siv IOT rau Adafruit IO thiab WiFi

Txuas Peb Cov Khoom Siv IOT rau Adafruit IO thiab WiFi
Txuas Peb Cov Khoom Siv IOT rau Adafruit IO thiab WiFi

Tam sim no peb tau teeb tsa Adafruit IO pub thiab IFTTT applet, peb yuav tau saib seb peb tuaj yeem cia cov kev pabcuam no sib tham nrog peb li IOT li cas.

  1. Qhib Arduino IDE.
  2. Mus rau Cov Ntaub Ntawv> Piv txwv> Adafruit IO Arduino> adafruitio_14_neopixel
  3. Mus rau lub tab thib ob hu ua "config.h"
  4. Hauv qab kab lus hais ua ntej hu ua "Adafruit IO Config" koj yuav pom cov kab no ntawm cov cai:

#define IO_USERNAME "koj_username"

#define IO_KEY "koj_key"

Hloov "koj_username" thiab "your_key" nrog koj Adafruit IO lub npe siv thiab tus lej AIO thiab tawm hauv cov lus hais.

Hauv qab kab lus thib ob yuav tsum muaj ob kab ntawm cov cai no:

#define WIFI_SSID "your_ssid" #define WIFI_PASS "your_pass"

Hloov "your_ssid" thiab "your_pass" nrog koj lub router WiFi cov ntaub ntawv pov thawj tawm hauv cov lus hais.

Tseem ceeb: koj Arduino tsuas yog ua haujlwm ntawm 2.4GHz tes hauj lwm. Txhawm rau txheeb xyuas yog tias koj lub network ua haujlwm ntawm qhov raug, mus rau koj lub khoos phis tawj WiFi teeb tsa> xaiv koj lub network> Khoom. Nrhiav qee yam ntawm kab "network band" thiab xyuas kom tseeb tias nws yog 2.4GHz. Ntawm Windows 10 nws zoo li hauv lub screenshot saum toj no.

Kauj Ruam 5: Tau Txais Peb Tes Dhau Nrog Arduino Code

Tau Txais Peb txhais tes qias neeg nrog Arduino Code
Tau Txais Peb txhais tes qias neeg nrog Arduino Code

Nyob rau hauv tib adafruit_14_neopixel kos duab raws li cov kauj ruam dhau los, nrhiav txhua kab nrog "xim" sau ntawv hauv lawv thiab hloov nws nrog "WindowCurtains". Tom qab ntawd ua tib yam nrog "neopixel" thiab hloov nws nrog "EasyWindow"

Hauv qab kab lus thib ob hu ua "Piv Txwv Pib Ntawm No", hloov chaw

#suav nrog "Adafruit_NeoPixel.h"

#define WINDOW_PIN 5

#define PIXEL_COUNT 5

nrog

#suav nrog "EasyWindow.h"

#define WINDOW_PIN 5

Thaum kawg ntawm qhov kev xa xov tsis muaj dab tsi, peb yuav sau thiab yog cov lus hais uas qhib peb Cov Qhov rai Qhov rai yooj yim yog tias cov xwm txheej no tau ua tiav:

yog (WindowCurtain.message == Qhib) {window.open (); } Koj tus lej kawg yuav tsum zoo li qhov no

// Adafruit IO RGB LED Cov Qauv Piv Txwv // // Adafruit nqis peev sijhawm thiab peev txheej muab qhov qhib qhov chaws no. // Thov txhawb Adafruit thiab qhib qhov khoom kho vajtse los ntawm kev yuav khoom // cov khoom lag luam los ntawm Adafruit! // // Sau los ntawm Todd Treece rau Adafruit Industries // Copyright (c) 2016-2017 Adafruit Industries // Muaj ntawv tso cai raws li MIT daim ntawv tso cai. // // Txhua cov ntawv sau saum toj no yuav tsum suav nrog txhua qhov kev faib tawm.

/************************** Kev teeb tsa ********************** *************

/ kho qhov config.h tab thiab sau koj li Adafruit IO cov ntaub ntawv pov thawj

// thiab ib qho kev teeb tsa ntxiv xav tau rau WiFi, xov tooj ntawm tes, // lossis cov neeg siv ethernet. #suav nrog "config.h"

/************************ Piv txwv pib ntawm no ********************** *********/

#suav nrog "EasyWindow.h"

#define WINDOW_PIN 5

// teeb tsa 'WindowCurtain' pub

AdafruitIO_Feed *WindowCurtain = io.feed ("WindowCurtain");

void teeb tsa () {

// pib qhov txuas txuas

Serial.begin (115200);

// tos kom saib xyuas kom qhib

thaum (! Serial);

// txuas rau io.adafruit.com

Serial.print ("Txuas rau Adafruit IO"); io.connect ();

// teeb tsa tus tuav tes xov rau 'WindowCurtain' pub.

// kev ua haujlwm handleMessage (txhais hauv qab no) // yuav raug hu thaum twg cov lus tau txais // tau txais los ntawm adafruit io. WindowCurtain-> onMessage (handleMessage);

// tos kev txuas

thaum (io.status () <AIO_CONNECTED) {Serial.print ("."); ncua (500); }

// peb txuas nrog

Serial.println (); Serial.println (io.statusText ()); WindowCurtain-> tau ();

// Easy Window init

window.begin (); }

void voj () {

// io.run (); yuav tsum muaj rau txhua daim duab.

// nws yuav tsum ib txwm nyob rau saum koj lub voj // ua haujlwm. nws ua rau cov neeg siv txuas nrog // io.adafruit.com, thiab ua haujlwm cov ntaub ntawv nkag. io.run ();

}

// txoj haujlwm no hu ua thaum twg los 'WindowCurtain' cov lus

// tau txais los ntawm Adafruit IO. nws tau txuas nrog // WindowCurtain pub hauv teeb tsa () ua haujlwm saum toj no. tsis muaj dab tsi handleMessage (AdafruitIO_Data *cov ntaub ntawv) {

// luam tawm RGB qhov tseem ceeb thiab tus lej hex

Serial.println ("Tau txais cov lus txib:"); Serial.println (data-> tus nqi ());

Ntev WindowCurtains = data-> toEasyWindow ();

yog (WindowCurtain.message == Qhib) {

qhov rai.open (); }}

Kauj Ruam 6: Upload Koj Cov Cai thiab Kuaj Nws

Rub koj tus lej thiab sim nws
Rub koj tus lej thiab sim nws

Tam sim no koj tuaj yeem xa koj cov cai rau koj pawg Arduino. Txuas nws mus rau koj lub khoos phis tawj nrog USB cable thiab nias lub pob "Upload" nyob rau ntawm kaum sab laug saum toj ntawm Arduino IDE (nws zoo li yog txoj cai taw qhia).

Yog tias txhua yam mus tau zoo, koj cov cai yuav tsum tau muab xa mus rau koj lub rooj tsavxwm yam tsis muaj kev duav. Koj tuaj yeem tshawb xyuas qhov xwm txheej sib txuas hauv IDE tus lej saib xyuas los ntawm Cov Cuab Yeej> Saib Xyuas Serial. Thaum koj lub cuab yeej txuas nrog, koj yuav tau txais cov lus hais tias "Txuas!" thiab yog tias nws pom meej sab nraud, IFTTT yuav xa cov lus "Qhib" mus rau "WindowCurtains" pub, ua rau Lub Qhov Yooj Yim Qhib qhib cov ntaub. Qhov no tseem yuav tsum tau tsom iav hauv kab ntawv saib nrog "Tau txais cov lus txib: Qhib".

Nrog koj zoo siab! Koj tau mus txog qhov kawg ntawm kev qhia thiab kawm paub yuav txuas koj li Arduino IOT li cas mus rau IFTTT thiab ua rau muaj xwm txheej tshwj xeeb.

Pom zoo: