Cov txheej txheem:
- Kauj Ruam 1: Txuas NodeMCU rau Wi-nkaus
- Kauj Ruam 2: Thov Cov Ntaub Ntawv Los Ntawm HTTPS Los Ntawm ANWB.nl
- Kauj Ruam 3: Hloov Cov Ntaub Ntawv Rau Cov Ntaub Ntawv Siv Tau
- Kauj Ruam 4: Txhim Kho Qhov Teeb Meem
- Kauj Ruam 5: Tsim Tswv Yim
- Kauj Ruam 6: Khiav Txoj Cai
Video: Txheeb Xyuas Daim Ntawv Qhia Txog Tsheb (NL) Nrog Doormat: 6 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Hauv cov lus qhia no kuv yuav piav qhia yuav tsim lub doormat uas yuav tshuaj xyuas cov ntaub ntawv qhia txog kev tsheb loj ntawm Dutch txoj kev loj. Thaum koj nqis mus rau sab nraud ntawm koj lub qhov rooj thiab muaj tsheb sib tsoo ntawm koj txoj kev, lub lev yuav tig mus rau xim liab. Thaum tsis muaj tsheb sib tsoo, lub lev yuav tig ntsuab.
Kuv yuav ua haujlwm ntawm NodeMCU 1.0 (ESP0-12E Module). Cov cai rau txoj haujlwm no tuaj yeem ua haujlwm ntawm lwm yam khoom siv ib yam nkaus (piv txwv li Arduino boards). Txoj haujlwm no yog ua raws li Dutch qhov chaw rau cov ntaub ntawv qhia txog tsheb, ANWB.
Peb xav tau dab tsi rau txoj haujlwm no:
- NodeMCU - Jumper cables - LEDlight lossis strip - Analog sensor (Aluminiuim foil, Sponge) - Wi -nkaus txuas - Doormat
Cov kauj ruam peb yuav tsum ua:
1. Txuas NodeMCu rau Wi-Fi 2. Thov cov ntaub ntawv ntawm HTTPS los ntawm ANWB.nl 3. Hloov cov ntaub ntawv mus rau cov ntaub ntawv siv tau 4. Txhim kho qhov ntsuas 5. Tsim cov lus tawm tswv yim
Kauj Ruam 1: Txuas NodeMCU rau Wi-nkaus
Cov kauj ruam no yuav qhia yuav ua li cas thiaj ua tiav HTTPSRequest kom pom seb lub cuab yeej txuas rau hauv internet.
Ua ntej tshaj, teeb tsa ESP8266 lub tsev qiv ntawv hauv Arduino IDE. Open los ntawm cov piv txwv ESP8266>
Sau koj li ntawv pov thawj Wi-nkaus rau saum koj tus lej, raws li qhia hauv qab no:
const char* ssid = "YOUR_SSID";
const char* password = "YOUR_PASS";
Tshaj tawm cov cai rau koj lub cuab yeej thiab tshawb xyuas yog tias NodeMCU txuas rau hauv is taws nem. HTTPSRequest piv txwv siv Github raws li nws lub hauv paus kom tau txais cov ntaub ntawv los ntawm. Thaum HTTPSRequest ua tiav, koj tau txais Github cov ntaub ntawv hauv cov ntawv xov xwm.
Kauj Ruam 2: Thov Cov Ntaub Ntawv Los Ntawm HTTPS Los Ntawm ANWB.nl
Hauv qib thib ob no, koj hloov cov ntaub ntawv los ntawm lub hauv paus mus rau qhov chaw xav tau rau txoj haujlwm no: ANWB.nl.
Nyob rau sab saum toj ntawm koj cov cai, hloov char* host rau www.anwb.nl (lossis lwm qhov chaw koj xav tau txais koj cov ntaub ntawv los ntawm):
const char* host = "www.anwb.nl";!! Yog tias koj siv lwm qhov chaw, qib 3 yuav txawv ntawm kuv cov cai. Kauj Ruam 3 xav tau cov cim tshwj xeeb kom rov qab tau cov ntaub ntawv siv tau!
Tom ntej no, hloov txoj hlua url hauv kev teeb tsa ua haujlwm rau "/txau/gethf", txoj hauv kev uas cov ntaub ntawv raug coj los ntawm:
Txoj hlua url = "/txau/gethf";!! Yog tias koj siv lwm qhov chaw siv txoj hauv kev rau koj qhov chaw!
Thaum koj upload cov cai koj yuav tsum tau txais cov lus teb nrog txhua cov ntaub ntawv los ntawm www.anwb.nl/feeds/gethf. Txoj cai no tau khaws tseg rau hauv txoj hlua hu ua kab.
Kauj Ruam 3: Hloov Cov Ntaub Ntawv Rau Cov Ntaub Ntawv Siv Tau
Txog tam sim no, txoj cai tsuas yog khiav thaum NodeMCU tau pib lossis rov pib dua, vim tias txhua txoj cai nyob hauv kev teeb tsa. Txhawm rau teeb tsa tus lej kom ua raws txoj cai txuas ntxiv, koj yuav tsum hloov txoj haujlwm ntawm txoj cai uas ua haujlwm thov HTTPS. Hauv qab lub voj ua haujlwm, koj ntxiv lwm txoj haujlwm. Kuv tau hu nws void extractData:
extractData () {cov
}
Luam ib feem ntawm cov cai los ntawm kev teeb tsa ua haujlwm rau hauv extractData (). Pib nrog cov kab hauv qab no kom txog thaum kawg ntawm kev teeb tsa:
yog (! client.connect (host, Txoj cai tam sim no nyob hauv koj txoj haujlwm tshiab, yog li tshem tawm cov cai theej los ntawm teeb tsa ua haujlwm.
Tom ntej no, hu rau extractData ua haujlwm hauv lub voj ua haujlwm thiab ntxiv qee qhov qeeb los muab lub sijhawm nodeMCU so:
void voj () {
extractData (); cov ncua (30000); // qhov no yuav raug tshem tawm tom qab thaum peb muaj qhov ntsuas qhov sib xws}
Txij li cov ntaub ntawv koj tau txais tau khaws cia rau hauv txoj hlua thiab tsuas yog ib feem ntawm txoj hlua no xav tau, koj yuav tsum sau ob peb ntawm loops.
Ua ntej, txheeb xyuas txhua txoj haujlwm ntawm lo lus 'txoj kev'. Tom qab lo lus 'txoj kev', lub npe ntawm txoj kev yuav ua raws (A1, A2, thiab lwm yam).
Ua ntej pib sau rau cov loops, koj yuav tsum tshaj tawm qee qhov kev hloov pauv uas koj yuav siv:
int noOfPos = 0;
boolean hasRunOnce = tsis tseeb; int ntawm = 0; int roadArray [20];
Tam sim no nws yog lub sijhawm los sau qee qhov loops. Kuv tau sau cov loops hauv qab ntawm qhov ua haujlwm extractData. Kuv tau sim faib nws ua cov haujlwm sib cais, tab sis kuv tsis tuaj yeem ua nws.
Rau lub voj tsis yog 1: nrhiav txoj haujlwm ntawm lo lus txoj hauv kab kab:
rau (int i = 0; kuv <line.length (); i ++) {int pos = line.indexOf ("txoj kev": ", los ntawm); roadArray [noOfPos] = pos; noOfPos+= 1; los ntawm = pos + 1; yog (hasRunOnce == muaj tseeb && pos == line.indexOf ("txoj kev \": ")) {i = line.length (); } hasRunOnce = muaj tseeb; }
Tom ntej no, txheeb xyuas seb txoj kev twg muaj tsheb sib tsoo, los ntawm kev siv txoj haujlwm ntawm lub voj los saum toj no. Txoj haujlwm ntawm lub npe txoj kev yeej zoo ib yam thiab pib 7 tus cim thiab xaus 10 tus cim tom qab lo lus txoj kev.
Tam sim no peb txhais cov npe arrayOfRoadArray, uas yuav tau sau rau tom ntej rau lub voj:
Txoj hlua nameOfRoadArray [20];
Rau lub voj tsis tau 2: Nrhiav txhua lub npe ntawm txoj kev nrog rau kev nkag los ntawm lub voj tsis tau. 1
rau (int k = 0; k <20; k ++) {int pos = roadArray [k]; int positionOfRoadName = pos + 7; int endOfPositionOfRoadName = pos + 10; nameOfRoadArray [k] = line.substring (positionOfRoadName, endOfPositionOfRoadName); }
Lub npe arrayOfRoudArray yuav tsum tau sau nrog txhua qhov kev tsheb ciav hlau cuam tshuam.
Tom ntej no, koj yuav tshuaj xyuas yog tias koj txoj kev nyob hauv txoj kev ntawm txoj kev uas muaj tsheb sib tsoo. Luam lub npeOfRoadArray kom tau txais txoj hauv kev hauv cov ntaub ntawv. Ua qhov no los ntawm kev ntxiv Serial.println (nameOfRoadArray [k]); rau hauv 2nd rau lub voj zoo li:
rau (int k = 0; k <20; k ++) {int pos = roadArray [k]; int positionOfRoadName = pos + 7; int endOfPositionOfRoadName = pos + 10; nameOfRoadArray [k] = line.substring (positionOfRoadName, endOfPositionOfRoadName); Serial.println (nameOfRoadArray [k]); }
Yog tias yog lawm koj yuav pom txhua txoj hauv kev uas muaj tsheb sib tsoo hauv Serial monitor.
Ua ntej sau qhov kawg Rau lub voj, koj yuav tsum tshaj tawm boolean raws li kev hloov pauv thoob ntiaj teb. Boolean, hu ua trafficJam yog los ntawm qhov tsis raug thiab yuav hloov pauv yog tias kev ua haujlwm extractData yuav rov qab muaj tseeb rau kev tsheb sib tsoo. Cov cai hauv qab no mus rau saum cov ntaub ntawv.ino:
boolean trafficJam = tsis tseeb;
Rau lub voj voos 3: Txheeb xyuas yog tias txoj kev, qhov no A1, nyob hauv daim ntawv teev cov tsheb sib tsoo.
rau (int l = 0; l <20; l ++) {if (nameOfRoadArray [l] == "A1 \" ") {// hloov A1 rau txoj kev uas koj nyiam trafficJam = muaj tseeb;}
Yog tias koj luam trafficJam hauv tus saib xov xwm, koj paub tias muaj tsheb khiav ntawm A1 lossis tsis yog.
Muab cov cai no rau hauv qab ntawm cov extractData muaj nuj nqi:
Serial.println (trafficJam); // saib yog tias muaj tsheb sib tsoo
Nrog cov ntaub ntawv no peb yuav ua haujlwm txuas ntxiv ntawm kev tawm tswv yim ntawm cov kab ke hauv qib 5.
Kauj Ruam 4: Txhim Kho Qhov Teeb Meem
Txij li tam sim no peb tuaj yeem khaws cov ntaub ntawv ua tiav los ntawm lub hauv paus, nws yog lub sijhawm los tsim lub ntsuas uas yuav ua rau nodeMCU los ua haujlwm lub luag haujlwm extractData. Kuv tau xaiv los ua ib qho analog sensor tawm ntawm kuv lub txaj. Koj tuaj yeem hloov qhov txhais los ntawm kev siv lwm lub sensor.
Tsim lub analog sensor
Kuv siv 2 daim ntawv txhuas, ob lub xov hlau txuas thiab daim txhuam cev.
Laum ib lub qhov hauv daim txhuam cev, qhov no yog qhov chaw uas txhuas cov foils yuav ua kev sib cuag. Kua nplaum txhuas ntawv ci ntawm ob sab ntawm daim txhuam cev. Txuas cov xov hlau txuas rau cov ntawv txhuas. Txuas cov xov hlau jumper mus rau nodeMCU. Ib sab rau A0-tus pin thiab lwm qhov rau V3-tus pin. Muab daim txhuam cev tso rau hauv koj lub qhov rooj thiab koj nyuam qhuav hloov koj lub qhov rooj los ua lub ntsuas pa. Zoo heev!
Txoj cai los nyeem tus nqi los ntawm lub ntsuas kom pom tias muaj leej twg sawv ntawm lub qhov rooj qhib:
int sensorValue = analogRead (A0);
yog (sensorValue == 1024) {extractData (); }
Thaum cov ntawv txhuas tau ua kev sib cuag (thaum ib tus neeg sawv ntawm lub lev), lub sensorValue yog 1024. Qhov no ua rau muaj nuj nqi extractData () rho tawm. Thiab qhov ntawd yog qhov peb xav kom lub kaw lus ua.
Kauj Ruam 5: Tsim Tswv Yim
Kuv siv LEDstrip los tawm tswv yim rau tus neeg siv. Thaum muaj tsheb sib tsoo, lub teeb yuav xim liab. Thaum txoj kev zoo mus, nws yuav tig ntsuab. Kuv siv lub tsev qiv ntawv adafruit neopixel los tswj kuv cov LEDstrip.
Sau cov cai no nyob rau sab saum toj ntawm koj cov ntaub ntawv kom paub tseeb tias LEDstrip tau hais tseg:
#suav nrog
#define PIXEL_PIN D5 #define PIXEL_COUNT 10 #define PIXEL_TYPE NEO_GRB + NEO_KHZ800 Adafruit_NeoPixel pixels = Adafruit_NeoPixel (PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
Sau tus lej tom ntej hauv kev teeb tsa ua haujlwm:
// neopixel
pixels.begin (); pixels.show ();
Thiab cov cai hauv qab no hauv kev ua haujlwm voj:
yog (trafficJam == muaj tseeb) {
rau (int kuv; kuv <PIXEL_COUNT; kuv ++) {pixels.setPixelColor (i, 255, 0, 0); // liab pixels.show (); ncua (200); }} lwm {rau (int kuv; kuv <PIXEL_COUNT; kuv ++) {pixels.setPixelColor (i, 0, 255, 0); // ntsuab pixels.show (); ncua (200); }
Hauv cov cai saum toj no muaj qhov if/else function. Thaum lub luag haujlwm rho tawm cov ntaub ntawv rov qab los ntawm qhov muaj cov tsheb sib tsoo LEDstrip yuav tig liab. Yog tsis yog, LEDstrip yuav tig ntsuab.
Kauj Ruam 6: Khiav Txoj Cai
Yog tias peb ua tiav txoj cai tam sim no, lub ntsuas cua thiab lub teeb yuav tsum ua haujlwm. Thaum koj sawv ntawm lub qhov rooj, lub ntsuas cua yuav txuas thiab lub extractData muaj nuj nqi yuav khiav. Thaum nyob hauv cov npe ntawm txoj kev, txoj kev peb tab tom nrhiav yog tam sim no, LEDstrip yuav tig liab, qhia tias muaj tsheb sib tsoo. Yog tias nws tsis nyob hauv kab, LEDstrip yuav tig ntsuab thiab koj paub tias koj zoo mus!
Muaj kev taug kev nyab xeeb thiab ua tsaug rau kev nyeem ntawv. Kuv vam tias koj pom qee qhov kev tshoov siab lossis cov ntaub ntawv. Yog tias koj tau txais qee cov lus tawm tswv yim, xav tias dawb los teb!
Pom zoo:
Txheeb Luam Tsis Muaj Software Tshwj Xeeb lossis Tshuab Luam Ntawv nrog MS Excel (Txheeb Xyuas Nyiaj Txiag Hauv txhab nyiaj): 6 Kauj Ruam
Txheeb Luam Tsis Muaj Software Tshwj Xeeb lossis Tshuab Luam Ntawv Nrog MS Excel (Txheeb Xyuas Nyiaj Txiag Nyiaj Txiag): Nov yog phau ntawv ua haujlwm yooj yim, uas yuav muaj txiaj ntsig zoo rau txhua lub lag luam los sau ntau cov txhab nyiaj hauv txhab nyiaj hauv ob rau lawv Cov Neeg Muag Khoom.yog koj tsis xav tau lub tshuab luam ntawv tshwj xeeb lossis software, tsuas yog koj xav tau yog khoos phis tawj nrog MS Excel thiab lub tshuab luam ntawv ib txwm.Yog, tam sim no koj tuaj yeem
Tsev Kawm Ntawv Nroog Tsev Kawm Ntawv Chaw Nres Tsheb Daim Ntawv Qhia: 7 Kauj Ruam (nrog Duab)
University Campus Student Parking Map: Ntau tus tub ntxhais kawm xav paub tias lawv tuaj yeem nres tsheb hauv lub tsev kawm ntawv qib siab li cas. Txhawm rau daws qhov teeb meem no, Kuv tsim daim duab qhia chaw nres tsheb ntawm thaj chaw tseem ceeb ntawm Utah State University lub tsev kawm ntawv. Daim duab qhia chaw yog rau cov tub ntxhais kawm kom nrawm nrawm saib seb qhov chaw nres tsheb twg yog
2019 FRC Sau Ntawv Qhia Txog Kev Cob Qhia Tsav Tsheb (Java): 5 Kauj Ruam
2019 FRC Sau Ntawv Qhia Txog Kev Cob Qhia Tsav Tsheb yooj yim (Java): Cov lus qhia no YUAV TSHUAJ TUG DATE! Txawm hais tias nws tsis dhau los tseem muaj qee yam uas koj tuaj yeem kawm txog nws zoo li yuav ua li cas thiaj ua tau cov chav kawm thiab sau cov cai
Kuv Me Me Whoop: Daim Ntawv Qhia Whoop + Cov Lus Qhia thiab Cov Lus Qhia: 8 Kauj Ruam
Kuv Me Me Whoop: Daim Ntawv Qhia Whoop + Cov Lus Qhia thiab Cov Lus Qhia: Kev Ceeb Toom: Tam sim no koj tab tom nkag mus rau kuv thawj qhov kev qhia, thiab koj yuav ntsib ntau yam kev ruam thiab tsis muaj phiaj xwm thiab/lossis txuj ci. Paub txog qhov no yog kuv tus kheej Tiny Whoop teeb tsa uas kuv siv txhua hnub, yog li kuv xav tias kuv yuav qhia nws. Nws yog phooj ywg mus ncig (tsis muaj
Hloov (tsuas yog Txog) Txhua Cov Ntaub Ntawv Xov Xwm rau (tsuas yog Hais Txog) Lwm Cov Ntaub Ntawv Xov Xwm Dawb!: 4 Cov Kauj Ruam
Hloov (tsuas yog Txog) Txhua Cov Ntaub Ntawv Xov Xwm rau (tsuas yog Hais Txog) Lwm Cov Ntaub Ntawv Xov Xwm Dawb!: Kuv thawj qhov kev qhia, zoo siab! Txawm li cas los xij, Kuv tau nyob hauv Google nrhiav qhov program dawb uas yuav hloov kuv li Youtube.flv cov ntaub ntawv rau hom ntawv uas yog ntau yam thoob ntiaj teb, zoo li.wmv lossis.mov.I tshawb nrhiav ntau lub rooj sib tham thiab cov vev xaib thiab tom qab ntawd pom qhov program hu ua