Cov txheej txheem:

Teeb pom kev nthuav qhia: 5 Kauj Ruam (nrog Duab)
Teeb pom kev nthuav qhia: 5 Kauj Ruam (nrog Duab)

Video: Teeb pom kev nthuav qhia: 5 Kauj Ruam (nrog Duab)

Video: Teeb pom kev nthuav qhia: 5 Kauj Ruam (nrog Duab)
Video: Qhia saib yus tus hlub lub xov tooj seb nws kov txog dab tsi thaum yus nyob deb 2024, Hlis ntuj nqeg
Anonim
Illuminated Presents
Illuminated Presents

Hauv tsev peb muaj ob lub teeb pom kev zoo uas tau siv thaum lub caij Christmas. Cov no yog cov teeb pom kev yooj yim siv 2 xim liab-ntsuab LED uas hloov pauv xim uas ploj mus thiab ploj mus. Cov cuab yeej siv los ntawm 3 Volt khawm ntawm tes. Qhov tom kawg yog qhov laj thawj rau txoj haujlwm no vim tias lub roj teeb tau qhuav sai heev thaum cov khoom plig tau siv rau lub sijhawm ntev dua.

Raws li txhawm rau tiv thaiv kev siv ntau ntawm cov khawm roj teeb ntawm tes Kuv tsim kuv tus kheej version siv peb lub roj teeb AAA them rov qab. Cov ntawv no siv RGB LED yog li xiav tseem tuaj yeem ua tau tab sis qhov ntawd tsis yog ib feem ntawm thawj qhov tsim. Kuv version muaj cov haujlwm hauv qab no:

  • Tswj 2 nthuav qhia tib lub sijhawm siv ib lub PIC12F617 microcontroller. Lub microcontroller software tau sau ua hom lus JAL.
  • Hloov qhov tam sim no rau thiab tawm siv lub laub khawm. Cov ntawv qub tau siv hloov pauv rau lub hom phiaj ntawd tab sis lub laub khawm tau yooj yim siv.
  • Hloov pauv xim ntawm qhov khoom plig los ntawm fade-in thiab ploj-tawm ntawm cov xim liab thiab ntsuab.
  • Hloov tawm qhov khoom plig thaum lub roj teeb hluav taws xob poob qis dua 3.0 Volt. Qhov no yuav tiv thaiv cov roj teeb uas rov los tau tawm ntau dhau.

Tom qab fading-hauv ib qho xim, LED nyob ib ntus ntawm 3 vib nas this thiab 20 vib nas this. Txij li thaum kuv tseem tsis tau siv lub xiav xiav Kuv tau ntxiv qhov tshwj xeeb uas ob lub pob yuav tig xiav thaum lub sijhawm yog raws nraim 10 vib nas this. Qhov no tsis tshwm sim ntau zaus txij li lub sijhawm tsis sib xws tau tsim nyob rau hauv timer zuam ntawm 40 milliseconds raws li tau piav tom qab.

Kauj Ruam 1: Qee Qhov Kev Xav Txog Fading-in thiab Fading Out Siv Pulse Width Modulation

Txoj hauv kev zoo tshaj plaws los hloov qhov ci ci ntawm LED tsis yog los ntawm kev hloov pauv tam sim no uas ntws los ntawm LED tab sis los ntawm kev hloov lub sijhawm LED nyob hauv ib lub sijhawm tshwj xeeb. Txoj hauv kev ntawm kev tswj qhov ci ntawm LED yog hu ua Pulse Width Modulation (PWM) uas tau piav qhia ntau zaus hauv is taws nem, piv txwv li. Wikipedia.

PIC thiab Arduino muaj PWM kho vajtse tshwj xeeb ntawm lub rooj tsavxwm uas ua rau nws yooj yim los tsim lub PWM teeb liab no tab sis lawv feem ntau muaj ib qho tso tawm rau qhov no thiab yog li koj tsuas tuaj yeem tswj tau ib qho LED. Rau cov ntawv no kuv xav tau los tswj 5 LEDs (2 liab, 2 ntsuab thiab 1 ua ke xiav) yog li PWM xav tau kom ua tiav hauv software siv lub sijhawm uas tsim ob qho PWM zaus ntxiv rau PWM lub voj voog ua haujlwm.

PIC12F617 muaj lub sijhawm nyob ntawm lub nkoj nrog lub peev xwm rov pib dua. Qhov no txhais tau tias thaum koj teeb tus nqi rov ua dua ntawm lub sijhawm, nws yuav siv tus nqi ntawd txhua lub sijhawm dhau sijhawm thiab yog li lub sijhawm ua haujlwm sawv ib leeg ntawm qhov tshwj xeeb zaus. Txij li lub sijhawm yog qhov tseem ceeb rau PWM ruaj khov teeb liab lub sijhawm ua haujlwm cuam tshuam, tsis muaj kev cuam tshuam los ntawm lub sijhawm qhov haujlwm tseem ceeb xav tau los tswj thiab txiav txim siab qhov tsis sib xws ntawm lub sijhawm rau LEDs.

PWM zaus yuav tsum siab txaus txhawm rau tiv thaiv kom tsis txhob pom qhov muag thiab yog li kuv tau xaiv PWM zaus ntawm 100 Hz. Rau qhov fade-in thiab fade-out effect peb yuav tsum hloov pauv lub luag haujlwm thiab yog li qhov ci ntawm LED. Kuv txiav txim siab siv ib qib zuj zus ntawm 5 txhawm rau nce lossis txo qhov ci ci kom tau txais qhov ploj-hauv thiab ploj zuj zus thiab vim tias lub sijhawm siv sijhawm ntau ntawm 0 txog 255 rau lub luag haujlwm, lub sijhawm xav tau khiav ntawm 255 / 5 = 51 zaus zaus ib txwm lossis 5100 Hz. Qhov no ua rau lub sijhawm cuam tshuam txhua 196 peb.

Kauj Ruam 2: Kev Ua Haujlwm Txhua Yam

Cov Neeg Ua Haujlwm Ua Haujlwm
Cov Neeg Ua Haujlwm Ua Haujlwm
Cov Neeg Ua Haujlwm Ua Haujlwm
Cov Neeg Ua Haujlwm Ua Haujlwm
Cov Neeg Ua Haujlwm Ua Haujlwm
Cov Neeg Ua Haujlwm Ua Haujlwm

Rau kev ua khoom plig Kuv siv mis yas dawb acrylic yas thiab rau qhov seem ntawm kev teeb tsa kuv siv MDF. Raws li kev tiv thaiv uas koj pom cov duab ntawm LED hauv pob thaum LED qhib, Kuv muab lub hau npog rau saum cov LEDs uas nthuav lub teeb los ntawm LED. Cov npog no tau los ntawm qee cov taws tswm ciab qub uas kuv muaj tab sis koj kuj tuaj yeem tsim lub hau npog los ntawm kev siv tib lub yas yas. Hauv cov duab koj pom yam kuv siv ua khoom siv thiab khoom siv.

Kauj Ruam 3: Cov Khoom Siv Hluav Taws Xob

Cov Electronics
Cov Electronics
Cov Electronics
Cov Electronics
Cov Electronics
Cov Electronics
Cov Electronics
Cov Electronics

Daim duab qhia chaw qhia cov khoom siv hluav taws xob uas koj xav tau. Raws li tau hais ua ntej 5 LEDs raug tswj ntawm nws tus kheej qhov twg lub xiav LED ua ke. Txij li PIC tsis tuaj yeem tsav ob lub LEDs ntawm ib tus pin chaw nres nkoj Kuv tau ntxiv lub transistor rau kev tswj hwm cov LED sib xyaw ua ke. Cov khoom siv hluav taws xob tau siv los ntawm 3 AAA roj teeb uas tuaj yeem them rov qab thiab tuaj yeem siv tau los yog tawm los ntawm kev nias lub pob pib dua.

Koj xav tau cov khoom siv hluav taws xob hauv qab no rau qhov haujlwm no:

  • 1 PIC microcontroller 12F617 nrog lub qhov (socket)
  • 2 Ceramic capacitors: 2 * 100nF
  • Resistors: 1 * 33k, 1 * 4k7, 2 * 68 Ohm, 4 * 22 Ohm
  • 2 RGB LEDs, siab ci
  • 1 BC557 transistor lossis sib npaug
  • 1 laub khawm hloov

Koj tuaj yeem tsim lub Circuit Court ntawm lub khob cij thiab tsis xav tau chaw ntau, raws li pom hauv daim duab. Koj yuav xav tsis thoob vim li cas tus tiv thaiv qhov tseem ceeb rau kev tswj hwm qhov siab tshaj tam sim no los ntawm LEDs yog li qis. Qhov no yog vim qhov muab hluav taws xob qis ntawm 3.6 Volt ua ke nrog qhov poob qis uas txhua tus LED muaj, uas nyob ntawm cov xim ib LED, kuj pom Wikepedia. Qhov ntsuas qhov ntsuas tau ua rau muaj qhov siab tshaj tam sim no ntawm ib puag ncig 15 mA rau ib qho LED qhov twg qhov siab tshaj plaws tam sim no ntawm tag nrho cov kab ke yog ib puag ncig 30 mA.

Kauj ruam 4: Software

Lub software ua cov haujlwm hauv qab no:

Thaum lub cuab yeej rov pib dua los ntawm lub laub khawm nws yuav qhib lub cuab yeej yog tias nws tau tawm lossis nws tig lub cuab yeej tawm yog tias nws tau qhib. Tawm txhais tau tias tso PIC12F617 rau hauv hom pw tsaug zog uas nws tsis tshua siv zog.

Tsim lub PWM teeb liab los tswj qhov ci ntawm LEDs. Qhov no yog ua tiav siv lub sijhawm thiab cuam tshuam cov kev pabcuam niaj hnub uas tswj cov pins ntawm PIC12F617 leej twg tig lawv cov LEDs rau thiab tawm.

Fade-in thiab fade-out cov LEDs thiab khaws cia rau ntawm lub sijhawm tsis sib xws ntawm 3 thiab 20 vib nas this. Yog tias lub sijhawm sib npaug sib npaug 10 vib nas this, ob qho tib si LEDs yuav tig xiav rau 10 vib nas this tom qab uas ib txwm liab-ntsuab ploj-hauv thiab fade-tawm qauv siv.

Thaum lub sijhawm ua haujlwm, PIC yuav ntsuas cov khoom siv hluav taws xob siv nws ntawm lub rooj sib tham Analog rau Digital Converter (ADC). Thaum qhov hluav taws xob poob qis dua 3.0 V, nws yuav hloov lub LEDs thiab yuav tso PIC rau hauv hom pw tsaug zog dua. PIC tseem tuaj yeem ua haujlwm tau zoo ntawm 3.0 V tab sis nws tsis zoo rau cov roj teeb uas tau them rov qab kom ua tiav.

Raws li tau hais ua ntej PWM teeb liab tau tsim los siv lub sijhawm ntsuas uas siv kev cuam tshuam kev pabcuam ib txwm ua kom ruaj khov PWM teeb liab. Lub fading-in thiab fading-tawm ntawm LEDs suav nrog lub sijhawm LEDs nyob, yog tswj los ntawm txoj haujlwm tseem ceeb. Qhov haujlwm tseem ceeb no siv lub sijhawm ntsuas ntawm 40 milliseconds, muab los ntawm tib lub sijhawm uas tsim PWM teeb liab.

Txij li thaum kuv tsis tau siv qee lub tsev qiv ntawv JAL tshwj xeeb rau txoj haujlwm no lub sijhawm no kuv yuav tsum ua lub tshuab hluav taws xob tsis zoo siv cov lus tawm tswv yim hloov pauv rau npe rau kev tsim lub sijhawm tsis raug thiab lub sijhawm tsis sib xws ntawm LEDs.

Kauj Ruam 5: Qhov Kawg

Image
Image
Qhov Kawg
Qhov Kawg

Muaj 2 daim vis dis aus uas qhia qhov tshwm sim nruab nrab. Kuv tus poj niam tseem yuav tsum tau hloov lub ntsuas rau hauv qhov khoom plig tiag tiag. Ib daim vis dis aus qhia txog qhov ze ntawm qhov tshwm sim qhov twg lwm cov vis dis aus qhia nws nrog thawj qhov tam sim no uas ua rau txoj haujlwm no.

Raws li koj tuaj yeem xav thaum koj xav tias koj ua tiav, qhov xav tau tshiab pop-up. Kuv tus poj niam tau thov yog qhov ci ntawm LEDs tuaj yeem sib txawv tom qab lawv tau ploj mus.

Cov ntaub ntawv JAL thiab cov ntaub ntawv Intel Hex rau kev ua haujlwm PIC tau txuas nrog. Yog tias koj xav siv PIC microcontroller nrog JAL - Pascal zoo li cov lus programming - mus ntsib JAL lub vev xaib.

Muaj kev lom zem ua Cov Lus Qhia thiab tos ntsoov rau koj cov kev xav thiab txiaj ntsig.

Pom zoo: