Cov txheej txheem:

Sine-ese Dragon: 10 Kauj Ruam (nrog Duab)
Sine-ese Dragon: 10 Kauj Ruam (nrog Duab)

Video: Sine-ese Dragon: 10 Kauj Ruam (nrog Duab)

Video: Sine-ese Dragon: 10 Kauj Ruam (nrog Duab)
Video: Только стакан этого сока ... Обратное забивание артерий и снижение высокого кровяного давления 2024, Hlis ntuj nqeg
Anonim
Sine-ese Zaj
Sine-ese Zaj

Sine-ese Dragon yog ib puag ncig lub tsev dai kom zoo nkauj uas siv cov khoom siv txav thiab teeb pom kev los qhia koj txog huab cua huab cua rau peb peb teev tom ntej. Los ntawm kev txhais, ib puag ncig piav qhia ib puag ncig tam sim ntawm ib yam dab tsi; li no nws tau txiav txim siab kom tsim nyog los suav nrog cov ntaub ntawv huab cua rau hauv cov khoom ib puag ncig. Huab cua yog ib yam uas hloov pauv tib neeg lub hnub tsis xwm txheej thiab yog ib qho xov xwm uas hloov pauv tas li txhua feeb, lossis txawm tias poob mus txog qhov thib ob.

Suav Suav yog "lub cim ntawm lub zog, lub zog, thiab hmoov zoo" thiab feem ntau muaj nyob rau ntawm kev coj noj coj ua thiab kev coj noj coj ua zoo nyob thoob plaws tebchaws Asia. Ntxiv nrog rau coj txoj hmoov zoo, Suav Suav tseem hais tias muaj lub zog muaj zog uas tswj tau "dej, nag, cua daj cua dub, thiab dej nyab." Thaum kawg, Suav Zaj tau pom tias tsim nyog los sawv cev txog cov ntaub ntawv huab cua.

Pom kev

Sine-ese Dragon tau siv rau ntawm lub ntsiab lus tseem ceeb ntawm peb ntu ntu cais qhia txog huab cua huab cua rau peb 3 teev ua ntu zus. Rau txhua ntu 3-teev, cov ntaub ntawv hauv qab no yuav suav nrog:

  • Kev piav qhia huab cua - txiav txim siab xim ntawm cov ntaub ntawv huab cua tam sim no.
  • Kub - qhia txog qhov siab ntawm lub cev
  • Vaum - ntsais muag ntawm ntu LED
  • Cua ceev - tswj kev nrawm ntawm lub cev txav mus rau sab laug thiab sab xis.

Cov Ntaub Ntawv Yuav Tsum Tau

  1. 3 hli plywood/Cardboard
  2. 5 hli ntoo dowels lossis chopsticks
  3. 2 Partons Photons
  4. 3 Slinky cov khoom ua si
  5. 6 servo tsav
  6. NeoPixel teeb (ib qho hlua lossis ib lub teeb sib txuas ua ke)
  7. Muaj ntau ntawm Super Glue
  8. Conductive xov
  9. Acrylic xim
  10. Hniav ntaub
  11. Laser txiav
  12. 3D tshuab luam ntawv

Kauj ruam 1: Nce thiab nqis

Saum thiab nqis!
Saum thiab nqis!
Saum thiab nqis!
Saum thiab nqis!
Saum thiab nqis!
Saum thiab nqis!

Koj thawj kauj ruam los tsim lub Sine-ese Dragon yog txhawm rau tsim cov khoom siv uas tswj kev nce thiab nqis ntawm lub cev. Zoo siab heev!

  1. Rub tawm Adobe Illustrator cov ntaub ntawv (.ai) thiab luam tawm lawv siv lub tshuab txiav laser.

    upDownBoxWithPlatform.ai yuav tsum luam tawm ntawm daim duab los qhia

  2. Rub tawm cov ntawv luam 3D (.stl) thiab siv koj lub tshuab luam ntawv 3D uas koj nyiam tshaj los luam tawm.

    Cov xim tsis muaj teeb meem rau lub disk lossis lub tig tig. Hauv daim duab thib ob, lub tshuab tig rov qab tau muab tso rau hauv lub qhov ntawm lub disk

  3. Sib sau ua ke ob ntu ua ke thiab lo lawv ua ke raws li qhia hauv duab 3 txog 5.

    1. Lub platform
    2. Cov grooves rau disc
  4. Tam sim no, muab tso ua ke lub thawv ua raws cov lus qhia hauv qab no.

    1. Cov servo cov xov hluav taws xob yuav tsum dhau los ntawm qhov qhib lub kaum sab xis ntawm ib sab ntawm lub npov.
    2. Qhov luv luv kawg ntawm lub disk tig tau txuas nrog lub taub hau servo thiab qhov ntev kawg mus hla lub qhov ntawm lwm sab ntawm lub npov nrog lub qhov ncig ntawm nws. Qhov no tau qhia hauv daim duab 6.
  5. Tam sim no, peb xav tau qee yam kom ntseeg tau tias lub platform nyob qis qis thaum lub disk tig. Txiav tus pas txhuam hniav rau hauv 75 hli ntev pas (daim duab 7) thiab lo lawv hla lub thawv sab saum toj mus rau sab saum toj ntawm lub platform siv cov kua nplaum kub. Nco ntsoov tias cov pas nrig tau qis ntawm 90 degrees mus rau lub platform.
  6. Ntxig tus pas ntev 212 hli rau hauv lub qhov nruab nrab nyob rau sab saum toj ntawm lub npov mus rau lub platform.

Qab zib! Tam sim no koj muaj lub thawv tiav (daim duab 8) rau kev nce thiab nqis txav ntawm zaj. Tam sim no, rov ua cov kauj ruam saum toj no ob zaug ntxiv!

Kauj Ruam 2: Dab Tsi Txog Sab laug thiab Txoj Cai?

Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!
Dab tsi txog Sab laug thiab Txoj Cai?!

Tam sim no, peb tsis tuaj yeem hnov qab txog sab laug thiab sab xis ntawm Sine-ese Dragon, puas yog? Cia peb dhia mus rau theem ob!

  1. Rub tawm Adobe Illustrator cov ntaub ntawv (.ai) thiab luam tawm lawv siv lub tshuab txiav laser.

    1. leftRightBoxWithPlatforms.ai yuav tsum luam tawm ntawm daim duab los qhia.
    2. armTurner.ai cov ntaub ntawv yuav tsum luam tawm ntawm cov khoom uas yog 3 hli tuab.
  2. Rub tawm cov ntawv luam 3D (.stl) thiab siv koj lub tshuab luam ntawv 3D uas koj nyiam tshaj los luam tawm.

    Nco ntsoov tias koj luam ob txhais caj npab! Cov xim tsis txawv ntawm no

  3. Sib sau ua ke ob lub platform ua ke raws li qhia hauv daim duab 3 siv cov kua nplaum kub.
  4. Muab tso rau hauv lub thawv. Txawm hais tias nws yuav nyuaj rau ua li ntawd, nws yooj yim dua los ntawm:

    1. Ntxig ob lub platform nruab nrab ntawm ob txoj kab loj nyob ntawm ob sab ntawm lub npov.
    2. Muab thawj caj npab tso rau saum lub platform siab.
    3. Threading caj npab tig los ntawm caj npab thiab tom qab ntawd lub platform siab.
    4. Muab ob txhais caj npab tso rau saum lub hauv paus hauv qab.
    5. Threading caj npab tig los ntawm ob txhais caj npab thiab tom qab ntawd hauv qab platform.
    6. Tuav caj npab tig los ntawm txoj kab plaub hau qhib ntawm 3D luam tawm caj npab tig.
    7. Lwm qhov kawg ntawm tus tig tig mus saum lub servo motor.
    8. Ntxiv sab saum toj, hauv qab, thiab thim rov qab rau hauv lub thawv.

Koj lub thawv sib dhos zaum kawg yuav tsum zoo li daim duab thib rau. Tam sim no, koj yuav tsum rov hais dua ob zaug ntxiv!

Los ntawm qhov kawg ntawm cov kauj ruam no, koj yuav tsum muaj rau lub thawv nrog peb txhua tus nce/nqis thiab sab laug/sab xis txoj kev txav mus los.

Kauj Ruam 3: Tuav Lub Cev … YUAV UA LI CAS?

Tuav Lub Cev … YUAV UA LI CAS?
Tuav Lub Cev … YUAV UA LI CAS?

Cov lus nug zoo! Qhov ntawd yog thaum cov neeg 3D luam cov neeg tuav lub qhov rooj tuaj. Rub cov ntawv.stl nrog thiab luam nws siv lub tshuab luam ntawv 3D. Nco ntsoov luam 6 tus tuav tag nrho rau 6 lub thawv sib txawv.

Yog tias koj tau pom daim duab ntawm tus tuav lub slinky saum toj no, qhov ua rau xav tsis thoob - qhov ntawd yog xim ntawm peb Sine -ese Dragon!

Kauj Ruam 4: Tab sis Cov Thawv Tsis Zoo Li No …

Thiab kuv pom zoo! Qhov no yog vim li cas peb thiaj yuav siv lub tshuab txiav laser txiav lub thawv uas ntxim nyiam kom muaj txhua lub thawv ntawd thiab zais lawv.

Rub cov Adobe Illustrator cov ntaub ntawv thiab txiav tawm siv lub tshuab txiav laser. Cov huab tsim tau txhais tes kos los ntawm ib tus koom nrog. Xav tias dawb los hloov lawv los ntawm kev tshem tawm lawv sab hauv daim duab qhia chaw thiab ntxiv koj tus kheej tsim raws li koj pom zoo! Hauv qab no yog cov lus pom zoo los ua txhua yam ua ke.

  1. Sib sau ua ke thiab lo tag nrho peb daim los ntawm thawj daim ntawv (txheej txheem txheej txheej sab nrauv_1) ua ke.
  2. Tsis txhob ntxiv ib daim los ntawm cov ntawv thib ob (txheej txheej txheej txheej txheej thib ob) tsis tau.
  3. Muab daim ntawv los ntawm daim ntawv thib peb (txheej sab nraud BoxFinal_3) rau hauv qab ntawm lub npov thiab nws yuav tsum kaw rau saum. KOV XWB XWB nyob hauv qab ntawm lub npov.
  4. Sau sab hauvBoxesPlatform ob zaug. Kaw ob daim uas muaj lub qhov loj hauv lub qhov hauv lawv ua ke. Tom qab ntawd, lo nplaum peb ntawm daim uas seem ua ke. Thaum kawg, lo nws rau lwm qhov glued teeb nrog qhov hauv lawv.
  5. Muab lub platform tso rau hauv qab ntawm lub thawv loj.
  6. Ntxig tag nrho 6 lub thawv me me rau hauv lawv qhov chaw sib xws ntawm lub platform.
  7. Tam sim no, muab daim los ntawm daim ntawv thib ob (txheej sab nrauv Box_2) nyob rau sab saum toj ntawm lub npov thiab muab lo rau ib ncig ntawm ntug. Cov qhov nyob rau sab saum toj yuav tsum ua kom haum nrog lub qhov ntawm lub thawv me me. Yog tsis yog, rov kho koj lub thawv me dua. Tsis txhob ntxiv kua nplaum rau lub thawv me me kiag li.
  8. Yog tias koj tab tom siv lub khob cij uas muaj daim nplaum rau hauv qab, tso qhov no ze rau nruab nrab ntawm daim hauv qab hauv qhov chaw uas thaum koj kaw lub thawv, lub khob cij nrog rau Photons yuav tsum ploj mus. Muaj cov qhov me me nyob hauv qab daim ntawv ua kom yooj yim rau koj txuas rau Photons los ntawm sab nraud.

Kauj Ruam 5: Cov Khoom Ua Si Slinky ?? Oh, Kuv

Cov khoom ua si Slinky ?? Oh, Kuv!
Cov khoom ua si Slinky ?? Oh, Kuv!
Cov khoom ua si Slinky ?? Oh, Kuv!
Cov khoom ua si Slinky ?? Oh, Kuv!

Lub cev ntawm zaj:

1. Muab peb lub slinkies ua ke siv cov kua nplaum kub los yog daim kab xev.

2. Ntsuas qhov ntev thiab txoj kab uas hla ntawm cov slinkies thiab txiav ib daim ntaub zoo nkauj.

3. Nqa ob qho kawg ntawm daim ntaub thiab xaws lawv ua ke.

4. Thaum koj ua tiav xaws lawv, xaub cov slinkies zoo li lub thom khwm.

5. Xaws qhov kawg ntawm qhov ntxig rau cov ntaub xaws.

Kauj Ruam 6: Luam Koj Zaj

3D luam qhov seem ntawm zaj:

1. Cov ntu raug coj los ntawm

2. Peb siv tsuas yog lub taub hau, ceg thiab ob lub qhov muag.

3. Tom qab 3D luam tawm ib feem, smoothen nws siv cov ntawv xuab zeb thiab acetone.

4. pleev xim rau qhov uas koj xav kho nws.

Kauj ruam 7: Lub sijhawm kom nce qib koj zaj nrog NeoPixels

Lub sijhawm kom nce qib koj Zaj nrog NeoPixels!
Lub sijhawm kom nce qib koj Zaj nrog NeoPixels!
Lub sijhawm kom nce qib koj Zaj nrog NeoPixels!
Lub sijhawm kom nce qib koj Zaj nrog NeoPixels!

Lub teeb ntu:

1. Koj tuaj yeem siv cov hlua neopixel los tsim lub teeb yog tias koj xav tau. (Peb khiav tawm ntawm cov hlua).

2. Peb siv 20 neopixel teeb thiab txuas nrog lawv siv cov xov hlau. Cov xov hlau no tau muab txuas rau lawv thiab txuas nrog lub photon siv cov xov liab kom nws phim cov ntsiab lus ntawm zaj.

3. Koj tseem tuaj yeem xaws koj lub teeb neopixel rau ntawm daim ntaub ntev, tab sis peb tsis siv lawv vim tias peb muaj cov nplaum ua los ntawm cov hlau.

Sib dhos ntawm cov ntu: Ruaj lub teeb pom kev sab hauv lub cev ntawm zaj los siv xov lossis xov hlau. Nco ntsoov tias koj tuaj yeem txuas lub teeb rau lub photon sab hauv lub thawv puag. Txuas lub taub hau, ceg thiab tus Tsov tus tw rau lub cev siv kua nplaum. Thaum lawv nyob hauv qhov chaw, ruaj ntseg lub cev rau hauv cov tuav uas peb tau luam tawm ua ntej. Tam sim no lub cev tau npaj los ua haujlwm.

Kauj Ruam 8: Lub Sijhawm Kawm

Txij li thaum peb yuav siv ob lub Partons Photons los ua haujlwm nrog rau rau cais servo motors (ib Photon tuaj yeem ua haujlwm nrog plaub), peb yuav sau ob daim cais tab sis cov lej zoo sib xws kom ua rau ntawm lub microcontrollers.

Tam sim no, rau thawj microcontroller…

Hauv Arduino file (.ino), suav nrog cov tsev qiv ntawv hauv qab no thiab txhais:

#suav nrog "neopixel.h"

#suav nrog "ArduinoJson.h"

#txhais PIXEL_PIN D4

#define PIXEL_COUNT 18

Tom ntej no, tshaj tawm cov kev hloov hauv qab no:

Adafruit_NeoPixel sawb = Adafruit_NeoPixel (PIXEL_COUNT, PIXEL_PIN);

Servo servoLeftRight_1; Kev pabcuam servoUpDown_1; Servo servoLeftRight_2; Servo servoUpDown_2; int positionLeftRight_1 = 0; int positionUpDown_1 = 0; int sab laugRight_1 = 1; int upDown_1 = 1; int positionLeftRight_2 = 100; // yuav tsum nyob nruab nrab ntawm 0 thiab 180 (hauv degrees) int positionUpDown_2 = 180; // yuav tsum nyob nruab nrab ntawm 0 thiab 180 (hauv qib) int sab laugRight_2 = 1; // 0 = sab laug, 1 = sab xis int upDown_2 = 1; // 0 = nce, 1 = down const size_t buffSizeCurrent = JSON_ARRAY_SIZE (1) + JSON_OBJECT_SIZE (1) + 2*JSON_OBJECT_SIZE (2) + JSON_OBJECT_SIZE (4) + JSON_OBJECT_SIZE (5) 390; const size_t bufferSizeForecast = 38*JSON_ARRAY_SIZE (1) + JSON_ARRAY_SIZE (38) + 2*JSON_OBJECT_SIZE (0) + 112*JSON_OBJECT_SIZE (1) + 39*JSON_OBJECT_SIZE (2) + JSON_JZ (5) + 76*JSON_OBJECT_SIZE (8) + 12490; Txoj hlua weatherArray [3]; Ntab temperatureArray [3]; Float humidityArray [3]; ntab windSpeedArray [3]; Txoj hlua timestampArray [3]; int upDownMaxDegree [3]; int sab laugRightSpeed [3]; String allData5DaysForecast;

Nyem rau qhov no kom paub teeb tsa webhooks. Thaum koj ua tiav, ntxiv cov lus tshaj tawm thiab cov haujlwm hauv qab no thiab hloov qhov tsim nyog yog tias tsim nyog:

tsis muaj dab tsi getWeather5DayForecast () {Particle.publish ("get_weather5DayForecast"); allData5DaysForecast = ""; } Timer timerWeatherForecast (60000, getWeather5DayForecast); tsis muaj dab tsi getCurrentWeather () {Particle.publish ("get_currentWeather"); } Timer timerWeatherCurrent (60000, getCurrentWeather);

Cov haujlwm hauv qab no tswj hwm qhov nce/nqis thiab sab laug/sab xis ntawm zaj:

void changeLeftRight1 () {if (leftRight_1) {positionLeftRight_1 = positionLeftRight_1 + leftRightSpeed [0]; yog (positionLeftRight_1> 100) {leftRight_1 = 0; }} lwm {positionLeftRight_1 = positionLeftRight_1 - leftRightSpeed [0]; yog (positionLeftRight_1 <0) {leftRight_1 = 1; }} servoLeftRight_1.write (positionLeftRight_1); }

void changeLeftRight2 () {

yog (leftRight_2) {positionLeftRight_2 = positionLeftRight_2 + leftRightSpeed [1]; yog (positionLeftRight_2> 100) {leftRight_2 = 0; }} lwm {positionLeftRight_2 = positionLeftRight_2 - leftRightSpeed [1]; yog (positionLeftRight_2 <0) {leftRight_2 = 1; }} servoLeftRight_2.write (positionLeftRight_2); }

void changeUpDown1 () {

yog (upDown_1) {positionUpDown_1 ++; yog (positionUpDown_1> upDownMaxDegree [0]) {upDown_1 = 0; }} lwm {positionUpDown_1--; yog (positionUpDown_1 <1) {upDown_1 = 1; }} servoUpDown_1.write (positionUpDown_1); }

void changeUpDown2 () {

yog (upDown_2) {positionUpDown_2 ++; yog (positionUpDown_2> upDownMaxDegree [1]) {upDown_2 = 0; }} lwm {positionUpDown_2--; yog (positionUpDown_2 <1) {upDown_2 = 1; }} servoUpDown_2.write (positionUpDown_2); }

Txhawm rau tuaj yeem hloov pauv qhov txav mus los hauv ntu, lub sijhawm tau tsim.

Timer timerLeftRight1 (100, hloovLeftRight1);

Timer timerLeftRight2 (100, hloovLeftRight2); Timer timerUpDown1 (10, changeUpDown1); Timer timerUpDown2 (10, changeUpDown2);

Cov teeb tsa teeb tsa thaum kawg ntxiv tom ntej. Nco ntsoov hloov qhov tsim nyog rau kab ntawm cov cai uas cuam tshuam nrog webhooks.

teeb tsa tsis muaj dab tsi () {// pib huab cua timer timerWeatherForecast.start (); timerWeatherCurrent.start (); // Neopixels strip.begin (); // Muab qhov pib zoo li pinMode thiab pib ua haujlwm ntawm no. // Teeb tsa Micro Servo servoLeftRight_1.attach (D1); servoUpDown_1.attach (D0); servoLeftRight_2.attach (D3); servoUpDown_2.attach (D2); servoLeftRight_1.write (positionLeftRight_1); // initialize servo txoj hauj lwm servoUpDown_1.write (positionUpDown_1); // initialize servo txoj hauj lwm servoLeftRight_2.write (positionLeftRight_2); // initialize servo txoj hauj lwm servoUpDown_2.write (positionUpDown_2); // initialize servo txoj hauj lwm timerLeftRight1.start (); timerLeftRight2.start (); timerUpDown1.start (); timerUpDown2.start (); // Qhib lub console Serial.begin (9600); ncua (2000); Serial.println ("Nyob zoo!"); // Sau npe mus rau get_weather5DayForecast thiab tau txais _currentWeather webhooks Particle.subscribe ("nuv-teb/get_weather5DayForecast", gotWeather5DayForecast, MY_DEVICES); Particle.subscribe ("nqe lus teb/get_currentWeather/0", gotCurrentWeatherData, MY_DEVICES); getCurrentWeather (); getWeather5DayForecast (); }

Lub voj ua haujlwm tsis siv rau txoj haujlwm no. Peb tsis tuaj yeem hnov qab lub luag haujlwm los tswj cov ntaub ntawv tau txais los ntawm webhooks!

void gotWeather5DayForecast (const char *kev tshwm sim, const char *cov ntaub ntawv) {allData5DaysForecast += cov ntaub ntawv; // txuag txhua cov ntaub ntawv rau ib txoj hlua. int allData5DaysForecastLen = allData5DaysForecast.length (); char tsis [allData5DaysForecastLen + 1]; allData5DaysForecast.toCharArray (tsis, allData5DaysForecastLen + 1); // tsim qhov tsis rau txoj hlua int bufferLength = sizeof (tsis); DynamicJsonBuffer jsonBufferWeather (tsis ntev); JsonObject & hauv paus = jsonBufferWeather.parseObject (tsis); // Xeem yog parsing ua tiav. yog (! rov qab; } int kuv = 1; JsonArray & npe = hauv paus ["npe"]; rau (JsonObject & currentObject: list) {yog (i <3) {JsonObject & main = currentObject ["main"]; ntab kub = lub ntsiab ["temp"]; int humidity = lub ntsiab ["humidity"]; JsonObject & huab cua = currentObject ["huab cua"] [0]; const char* weatherInfo = huab cua ["tseem ceeb"]; ntab windSpeed = currentObject ["cua"] ["ceev"]; const char* timestamp = currentObject ["dt_txt"]; int tempFah = convertToFahrenheit (kub); int servoMaxDegree = updateUpDown (tempFah); upDownMaxDegree [kuv] = servoMaxDegree; int servoIncrement = updateleftRight (windSpeed); leftRightSpeed = servoIncrement; setColor (weatherInfo, kuv); temperatureArray [kuv] = tempFah; humidityArray [kuv] = av noo; weatherArray [kuv] = weatherInfo; windSpeedArray [kuv] = cua hlob; timestampArray [kuv] = timestamp; kuv ++; } lwm {tawg; }}}

void gotCurrentWeatherData (const char *event, const char *data) {DynamicJsonBuffer jsonBufferWeather (bufferSizeCurrent); JsonObject & hauv paus = jsonBufferWeather.parseObject (cov ntaub ntawv); // Xeem yog parsing ua tiav. yog (! root.success ()) {//Serial.println("Parsing rau huab cua tam sim no … YOOJ YIM! "); rov qab; } JsonObject & huab cua = hauv paus ["huab cua"] [0]; const char* weather_main = huab cua ["tseem ceeb"]; JsonObject & lub ntsiab = hauv paus ["lub ntsiab"]; ntab main_temp = lub ntsiab ["temp"]; int main_humidity = lub ntsiab ["av noo"]; ntab cua_speed = hauv paus ["cua"] ["nrawm"]; const char* timestamp = hauv paus ["dt_txt"]; int tempFah = convertToFahrenheit (main_temp); int servoMaxDegree = updateUpDown (tempFah); upDownMaxDegree [0] = servoMaxDegree; int servoIncrement = updateleftRight (cua_speed); leftRightSpeed [0] = servoIncrement; setColor (huab cua_main, 0); weatherArray [0] = huab cua_main; temperatureArray [0] = tempFah; humidityArray [0] = main_humidity; windSpeedArray [0] = cua_speed; timestampArray [0] = timestamp; }

Hauv qab no, koj tuaj yeem pom cov haujlwm ntxiv uas tswj kev hloov kho ntawm servo motors txoj haujlwm, kev hloov pauv kub ntawm Kelvin mus rau Fahrenheit thiab teeb tsa cov xim ntawm LEDs.

int updateUpDown (ntab temp) {// Qhia cov qib mus rau thaj tsam ntawm [0, 180] ntab servoMaxDegree = temp * 45 /31 + (990 /31); Serial.print ("qib servo tshiab:"); Serial.println (servoMaxDegree); rov qab servoMaxDegree; }

int updateleftRight (ntab windSpeed) {

// Daim ntawv qhia cua nrawm mus rau qhov ntau ntawm [1, 100] ntab servoIncrement = windSpeed * 99 /26 + 1; Serial.print ("tus nqi pabcuam tshiab ntxiv:"); Serial.println (servoIncrement); rov qab servoIncrement; }

int convertToFahrenheit (ntab tempKel) {

int tempFah = tempKel * 9.0 / 5.0 - 459.67; rov tempFah; }

tsis muaj dab tsi setColor (String weatherDesc, int index) {

int ledIndex = 0; yog (index == 0) {ledIndex = 0; } lwm yog (index == 1) {ledIndex = 6; } lwm yog (index == 2) {ledIndex = 12; } lwm {xa rov qab; } yog (weatherDesc == "Clear") {// daj rau (int j = ledIndex; j <ledIndex+6; j ++) {strip.setPixelColor (j, strip. Color (253, 219, 62)); // daj daj.show (); ncua (20); }} lwm yog (weatherDesc == "Huab") {// grey rau (int j = ledIndex; j <ledIndex+6; j ++) {strip.setPixelColor (j, strip. Color (223, 229, 237))); // grey strip.show (); ncua (20); }} lwm yog (weatherDesc == "Snow") {// dawb rau (int j = ledIndex; j <ledIndex+6; j ++) {strip.setPixelColor (j, strip. Color (255, 225, 225))); // dawb strip.show (); ncua (20); }} lwm yog (weatherDesc == "Rain") {// xiav rau (int j = ledIndex; j <ledIndex+6; j ++) {strip.setPixelColor (j, strip. Color (119, 191, 246))); // xiav strip.show (); ncua (20); }} lwm {// liab rau (int j = ledIndex; j <ledIndex+6; j ++) {strip.setPixelColor (j, strip. Color (254, 11, 5)); // liab strip.show (); ncua (20); }}}

Thaum koj tau txais txhua yam ntxiv rau koj cov ntaub ntawv Arduino, suav nws. Yog tias tsis muaj qhov yuam kev, mus tom ntej thiab nyem qhov chaws rau thawj Photon. Cov kauj ruam tom ntej yuav muab cov lej zoo sib xws rau koj rau ntawm lub thib ob Photon.

Kauj Ruam 9: Kev Kawm Txuas Ntxiv

Vim tias cov lej rau Photon thib ob yuav luag zoo ib yam rau thawj tus, tag nrho cov cai tau theej thiab muab tso rau hauv qab no:

#suav nrog "ArduinoJson.h"

Servo servoLeftRight_3;

Kev pabcuam servoUpDown_3;

int positionLeftRight_3 = 45;

int positionUpDown_3 = 0; int sab laugRight_3 = 1; int upDown_3 = 1;

const size_t bufferSizeCurrent = JSON_ARRAY_SIZE (1) + JSON_OBJECT_SIZE (1) + 2*JSON_OBJECT_SIZE (2) + JSON_OBJECT_SIZE (4) + JSON_OBJECT_SIZE (5) + JSON_OBJECE (12)

const size_t bufferSizeForecast = 38*JSON_ARRAY_SIZE (1) + JSON_ARRAY_SIZE (38) + 2*JSON_OBJECT_SIZE (0) + 112*JSON_OBJECT_SIZE (1) + 39*JSON_OBJECT_SIZE (2) + JSON_JZ (5) + 76*JSON_OBJECT_SIZE (8) + 12490;

Txoj hlua weatherArray [3];

Ntab temperatureArray [3]; Float humidityArray [3]; ntab windSpeedArray [3]; Txoj hlua timestampArray [3]; int upDownMaxDegree [3]; int sab laugRightSpeed [3];

String allData5DaysForecast;

tsis muaj dab tsi getWeather5DayForecast ()

{Particle.publish ("get_weather5DayForecast2"); allData5DaysForecast = ""; }

Timer timerWeatherForecast (60000, getWeather5DayForecast); // 10, 800, 000 ms = 3 hnub

tsis muaj dab tsi getCurrentWeather ()

{Particle.publish ("get_currentWeather2"); }

Timer timerWeatherCurrent (60000, getCurrentWeather);

void changeLeftRight3 () {

yog (leftRight_3) {positionLeftRight_3 = positionLeftRight_3 + leftRightSpeed [2]; yog (positionLeftRight_3> 100) {leftRight_3 = 0; }} lwm {positionLeftRight_3 = positionLeftRight_3 - leftRightSpeed [2]; yog (positionLeftRight_3 <0) {leftRight_3 = 1; }} servoLeftRight_3.write (positionLeftRight_3); }

void changeUpDown3 () {

yog (upDown_3) {positionUpDown_3 ++; yog (positionUpDown_3> upDownMaxDegree [2]) {upDown_3 = 0; }} lwm {positionUpDown_3--; yog (positionUpDown_3 <1) {upDown_3 = 1; }} servoUpDown_3.write (positionUpDown_3); }

Timer timerLeftRight3 (100, hloovLeftRight3);

Timer timerUpDown3 (10, hloovUpDown3);

void teeb tsa () {

// pib huab cua timer timerWeatherForecast.start (); timerWeatherCurrent.start (); // Muab qhov pib zoo li pinMode thiab pib ua haujlwm ntawm no. // Teeb tsa Micro Servo servoLeftRight_3.attach (D1); servoUpDown_3.attach (D0);

servoLeftRight_3.write (positionLeftRight_3); // initialize servo txoj hauj lwm

servoUpDown_3.write (positionUpDown_3); // initialize servo txoj hauj lwm

timerLeftRight3.start ();

timerUpDown3.start (); // Qhib lub console Serial.begin (9600); ncua (2000); Serial.println ("Nyob zoo!"); // Sau npe mus rau get_weather5DayForecast thiab tau txais_currentWeather webhooks Particle.subscribe ("nqe lus teb/tau txais _weather5DayForecast2", tauWeather5DayForecast, MY_DEVICES); Particle.subscribe ("nuv-teb/get_currentWeather2/0", gotCurrentWeatherData, MY_DEVICES); getCurrentWeather (); getWeather5DayForecast (); }

tsis muaj dab tsi gotWeather5DayForecast (const char *kev tshwm sim, const char *cov ntaub ntawv)

{allData5DaysForecast += cov ntaub ntawv; // txuag txhua cov ntaub ntawv rau ib txoj hlua. int allData5DaysForecastLen = allData5DaysForecast.length (); char tsis [allData5DaysForecastLen + 1]; allData5DaysForecast.toCharArray (tsis, allData5DaysForecastLen + 1); // tsim qhov tsis rau txoj hlua int bufferLength = sizeof (tsis); DynamicJsonBuffer jsonBufferWeather (tsis ntev); JsonObject & hauv paus = jsonBufferWeather.parseObject (tsis); //Serial.println(allData5DaysForecast); // Xeem yog parsing ua tiav. yog (! rov qab; } int kuv = 1; JsonArray & npe = hauv paus ["npe"]; rau (JsonObject & currentObject: list) {yog (i <3) {JsonObject & main = currentObject ["main"]; ntab kub = lub ntsiab ["temp"]; int humidity = lub ntsiab ["humidity"]; JsonObject & huab cua = currentObject ["huab cua"] [0]; const char* weatherInfo = huab cua ["tseem ceeb"]; ntab windSpeed = currentObject ["cua"] ["ceev"]; const char* timestamp = currentObject ["dt_txt"]; int tempFah = convertToFahrenheit (kub); int servoMaxDegree = updateUpDown (tempFah); upDownMaxDegree [kuv] = servoMaxDegree; int servoIncrement = updateleftRight (windSpeed); leftRightSpeed = servoIncrement; temperatureArray [kuv] = tempFah; humidityArray [kuv] = av noo; weatherArray [kuv] = weatherInfo; windSpeedArray [kuv] = cua hlob; timestampArray [kuv] = timestamp; kuv ++; } lwm {tawg; }}}

tsis muaj dab tsi gotCurrentWeatherData (const char *kev tshwm sim, const char *cov ntaub ntawv)

{DynamicJsonBuffer jsonBufferWeather (bufferSizeCurrent); JsonObject & hauv paus = jsonBufferWeather.parseObject (cov ntaub ntawv); //Serial.println(data); // Xeem yog parsing ua tiav. yog (! root.success ()) {//Serial.println("Parsing rau huab cua tam sim no … YOOJ YIM! "); rov qab; } JsonObject & huab cua = hauv paus ["huab cua"] [0]; const char* weather_main = huab cua ["tseem ceeb"]; JsonObject & lub ntsiab = hauv paus ["lub ntsiab"]; ntab main_temp = lub ntsiab ["temp"]; int main_humidity = lub ntsiab ["av noo"]; ntab cua_speed = hauv paus ["cua"] ["nrawm"]; const char* timestamp = hauv paus ["dt_txt"]; int tempFah = convertToFahrenheit (main_temp); int servoMaxDegree = updateUpDown (tempFah); upDownMaxDegree [0] = servoMaxDegree; int servoIncrement = updateleftRight (cua_speed); leftRightSpeed [0] = servoIncrement; weatherArray [0] = huab cua_main; temperatureArray [0] = tempFah; humidityArray [0] = main_humidity; windSpeedArray [0] = cua_speed; timestampArray [0] = timestamp; }

int updateUpDown (ntab temp) {

// Qhia daim ntawv qhia qib mus rau qhov ntau ntawm [0, 180] ntab servoMaxDegree = temp * 45 /31 + (990 /31); Serial.print ("qib servo tshiab:"); Serial.println (servoMaxDegree); rov qab servoMaxDegree; }

int updateleftRight (ntab windSpeed) {

// Daim ntawv qhia cua nrawm mus rau qhov ntau ntawm [1, 100] ntab servoIncrement = windSpeed * 99 /26 + 1; Serial.print ("tus nqi pabcuam tshiab ntxiv:"); Serial.println (servoIncrement); rov qab servoIncrement; }

int convertToFahrenheit (ntab tempKel) {

int tempFah = tempKel * 9.0 / 5.0 - 459.67; rov tempFah; }

Koj ua nws! Koj tau ua tiav los ntawm ntu ntu ntawm qhov haujlwm! Tam sim no, nco ntsoov ua kom tag nrho cov thaiv thiab kev sib txuas los ntawm servo motors thiab neopixels mus rau lub khob cij thiab microcontrollers. Lwm qhov kawg yuav tsum txuas nrog lub cev ntawm zaj.

Kauj ruam 10: Txaus siab rau koj Zaj

Nrog koj zoo siab! Koj tau tsim Sine-ese Dragon los ntawm kos! Tam sim no txhua yam koj yuav tsum ua yog zaum rov qab thiab txaus siab rau koj cov zaub ib puag ncig!

NCO TSEG: Txoj haujlwm no tau tsim los ua ib feem ntawm chav kawm los ntawm Joan Bempong thiab Soundarya Muthuvel. Nplooj ntawv chav kawm tuaj yeem pom ntawm no.

Pom zoo: