Cov txheej txheem:

Scary Pumpkin Candy Machine rau Xus: 5 Kauj Ruam
Scary Pumpkin Candy Machine rau Xus: 5 Kauj Ruam

Video: Scary Pumpkin Candy Machine rau Xus: 5 Kauj Ruam

Video: Scary Pumpkin Candy Machine rau Xus: 5 Kauj Ruam
Video: Грабители Конфет Vs Миска для Конфет с Сюрпризом 2024, Hlis ntuj nqeg
Anonim
Image
Image

Nyob zoo txhua tus! Nyob zoo Holloween !! Peb tau tsim lub teeb taub dag uas yuav ua suab paj nruag thiab hnia cov khaub noom qab zib thaum muaj leej twg tuaj txog nws.

Kauj Ruam 1: Yam Khoom Siv Hauv Txoj Haujlwm no

Yam Khoom Siv Hauv Txoj Haujlwm no
Yam Khoom Siv Hauv Txoj Haujlwm no
Yam Khoom Siv Hauv Txoj Haujlwm no
Yam Khoom Siv Hauv Txoj Haujlwm no

Cov khoom siv kho vajtse

  • Arduino UNO / Seeeduino V4.2
  • Lub hauv paus ntaub thaiv npog V2
  • Grove - PIR Tsab ntawv tsa suab Sensor
  • Grove - MP3 v2.0
  • Grove - WS2813 RGB LED Sawb Waterproof - 60 LED/m - 1m
  • EMax 12g ES08MD siab Sensitive servo

Software apps thiab cov kev pabcuam online

Arduino IDE Cov

Kauj ruam 2: Zaj dab neeg

Dab neeg
Dab neeg
Dab neeg
Dab neeg
Dab neeg
Dab neeg

Halloween los txog, teeb taub dag yog qhov tseem ceeb. Peb siv Seeeduino thiab PIR Motion Senser ua lub teeb taub dag, thaum qee leej los txog rau nws, nws yuav ua suab paj nruag thiab nto qaub ncaug.

Cov neeg kho tshuab qauv

** Kauj Ruam 1: ** Yuav qee cov khoom qab zib thiab taub dag, khawb lub qhov taub tom qab taub dag kom peb tuaj yeem tso Seeeduino rau nws.

** Kauj Ruam 2: ** Txiav lub npov zoo li no, thiab kho nws lub qhov taub ntawm taub dag.

** Setp 3: ** Mount caj npab rau servo motor. Txhawm rau txhim kho lub cav servo sab hauv taub dag, peb siv lub raj mis ua tus tuav.

** Kauj Ruam 4: ** Nco ntsoov thaum lub tshuab servo caj npab tig, cov khoom qab zib hauv lub npov yuav ntuav tawm los ntawm taub dag lub qhov ncauj.

Kauj Ruam 3: Kev Kho Vajtse Txuas

** Kauj Ruam 1: ** Ua daim nplaub tshev npe hu ua MP3 hauv daim npav SD, luam daim ntawv mp3 rau nws, npe nws 0001.mp3. Txuas tus neeg hais lus rau MP3 Grove's ntawm 3.5mm chaw nres nkoj, thiab txuas MP3 Grove mus rau chaw nres nkoj D2 ntawm Base Shield.

** Kauj Ruam 2: ** Txuas PIR Motion Sensor Grove rau Base Shield's D4 chaw nres nkoj, thiab txuas NeoPixel sawb rau Base Shield's D5 chaw nres nkoj.

** Kauj Ruam 3: ** Txuas Servo Grove rau Base Shield tus pin 9, yog li peb yuav xav siv DuPont kab.

** Kauj Ruam 4: ** ntsaws Base Shield rau Seeeduino.

** Kauj Ruam 5: ** Txhawm rau rub tawm qhov program mus rau Seeeduino, peb siv USB cable txuas nrog lub khoos phis tawj. Tom qab rub tawm, peb tsuas tuaj yeem siv lub hwj huam txuas hauv taub taub.

Kauj ruam 4: Software Programming

** Kauj Ruam 1: ** Nruab Lub Tsev Qiv Ntawv

Txhawm rau ua kom zoo dua qub, peb siv cov txheej txheem ua haujlwm hu ua FreeRTOS, nws tuaj yeem rub tawm los ntawm no.

Dhau li, txoj haujlwm no xav tau cov tsev qiv ntawv hauv qab no, rub tawm thiab teeb tsa lawv:

  • Grove - MP3 v2.0
  • Adafruit NeoPixel
  • Adafruit TicoServo

Lossis koj tuaj yeem yooj yim suav nrog MP3.h hauv qhov project kom siv MP3 Grove.

** Kauj Ruam 2: ** Tsim thiab tso cov program

*CEEB TOOM: Marco MAX_BRIGHTNESS tswj qhov ci tshaj plaws ntawm NeoPixel, txo qhov ci ci ntawm nws kom txo kev siv zog.*

Nws yuav nyuaj rau nkag siab txog txoj haujlwm yog tias koj tsis tau siv lub operating system ntawm Seeeduino ua ntej, kab lus hauv qab no yuav ua rau nws yooj yim.

Hauv kev teeb tsa () txheej txheem, peb tau pib ua ntu zus, MP3 Grove thiab Servo Motor ib txwm, thiab tsim qhov sib txawv uas peb hu ua semaphore, koj tuaj yeem txiav txim siab nws ua tus chij sib txawv uas siv los qhia tias nws yog leej twg tuaj lossis tsis yog.

vSemaphoreCreateBinary (xPIRBinarySemaphore);

Tom qab ntawd peb tsim 3 txoj haujlwm, lawv tuaj yeem khiav ua ke. Tab sis qhov tseem ceeb ntawm qhov ntawd yuav tsis zoo ib yam.

s1 = xTaskCreate (vFadingLEDsTask, NULL, configMINIMAL_STACK_SIZE, NULL, 1, NULL);

s2 = xTaskCreate (vScaningPIRTask, NULL, configMINIMAL_STACK_SIZE, NULL, 1, NULL); s3 = xTaskCreate (vHandlePIRTask, NULL, configMINIMAL_STACK_SIZE, NULL, 2, NULL);

Tom qab txheeb xyuas semaphore thiab cov haujlwm tau pib ua kom raug, vTaskSetartScheduler () txoj hauv kev pib tag nrho FreeRTOS.

yog (xPIRBinarySemaphore == NULL || s1! = pdPASS || s2! = pdPASS || s3! = pdPASS)

{rau (;;); } vTaskStartScheduler ();

Lub voj () txoj kev nerver siv hauv FreeRTOS. Tam sim no tus so yog qhov yooj yim, vFadingLEDsTask ua haujlwm fading Variable Color LED thiab vScanPIRTask ua haujlwm scan PIR Motion Sensor 'tus pin txhua lub sijhawm. Thaum PIR Motion Sensor pom qee tus neeg tuaj, nws teeb tus chij, tom qab ntawd vHandlePIRTask txoj haujlwm pib ua haujlwm. Vim tias qhov tseem ceeb ntawm vHandlePIRTask txoj haujlwm yog 2, thaum nws tab tom ua haujlwm, lwm qhov ob txoj haujlwm tseem tshuav yuav raug ncua.

Cov lus hauv qab no tau siv los teeb tsa lossis rov pib dua tus chij.

xSemaphoreGive (xPIRBinarySemaphore);

xSemaphoreTake (xPIRBinarySemaphore, portMAX_DELAY);

Kauj ruam 5: Kev ua haujlwm

Muab tus neeg hais lus, Seeeduino thiab Groves sab hauv lub teeb taub taub, thiab tso lub zog rau. Tam sim no koj tuaj yeem tos ib tus neeg los rau nws, Ua kom yuam kev lossis Kho:-).

Txheeb cov vis dis aus los ntawm txhaj Xus taub dag lub teeb. (https://www.youtube.com/embed/CFjuWXOIUN4)

Pom zoo: