Cov txheej txheem:
Video: Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812: 7 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:24
Los ntawm arduinocelentanoFollow Ntxiv los ntawm tus sau:
Nov yog lub teeb pom kev zoo uas tsis muaj nqi nrog plaub hom.
1. Zaj sawv. Lub txim ntawm lub teeb txav mus rau lub sijhawm dhau los tom qab lub sijhawm thiab maj mam hloov xim.
2. Zaj sawv ci. Lub ci ci ruaj khov uas maj mam hloov xim.
3. Tswmciab simulation hluav taws.
4. Tawm.
Koj tuaj yeem hloov pauv hom los ntawm kev kov lub pob nyem nyob rau sab saum toj. Hom tam sim no tau khaws tseg hauv EEPROM nco tom qab tua hluav taws.
Yuav ua li cas me me yog ATtiny13?
Lub tswv yim yog kom tau txais cov yam ntxwv zoo tshaj plaws los ntawm kho vajtse yam tsawg kawg nkaus, qee yam nyuaj dua qhov hloov pauv lossis ntsuas kub, qhov haujlwm ze rau ntawm ntug ntawm lub microcontroller me me. Tom qab tag nrho, kev txwv ua rau koj xav tias muaj tswv yim, txoj cai? Zoo, nws zoo li nws thaum pib.
Qhov nyuaj tshaj plaws hauv txoj haujlwm no yog thawb tag nrho cov cai rau hauv ATtiny13. Lub microcontroller muaj 1K bytes nyem thiab tsuas yog 64 bytes RAM. Yog, thaum kuv hais "bytes", kuv txhais cov uas suav nrog yim khoom. 64 bytes rau tag nrho koj cov kev hloov pauv hauv zos thiab hu rau pawg. Txhawm rau kom meej, txiav txim siab peb yuav tsum tswj 8 RGB LEDs. Txhua tus ntawm lawv tau txhais los ntawm 3 bytes (ib qho rau liab, ntsuab thiab xiav channel feem). Yog li, tsuas yog khaws lub xeev ntawm 8 LEDs, peb yuav xav tau siv cov txheej txheem ntawm 8 cov qauv 3 bytes txhua tus thiab tus taw qhia mus rau qhov pib ntawm kab ntawv no yuav siv ib qho ntxiv. Yog li, 25 ntawm 64 bytes tau tawm. Peb tsuas yog siv 39% ntawm RAM thiab tseem tsis tau pib tiag tiag. Ib qho ntxiv, txhawm rau khaws xya qhov xim xim zaj sawv, koj yuav xav tau 7 × 3 = 21 bytes, yog li 72% ntawm RAM tawm. Zoo, raws li rau cov xim yooj yim, Kuv hais ntau dhau: peb tsis xav tau tag nrho lawv nyob rau tib lub sijhawm hauv RAM thiab lawv yeej tsis hloov pauv, yog li lawv yuav raug siv raws li qhov tsis tu ncua kom khaws cia hauv flash hloov ntawm RAM. Xijpeem, nws muab qhov kev xav tag nrho txog kev siv kho vajtse.
Nco txog Knuth cov lus hais txog kev ua kom zoo ua ntej, Kuv pib los ntawm kev tsim qauv peb lub teeb teeb sib cais kom pom dab tsi tshwm sim. Kuv tau sim lawv cais kom paub tseeb tias lawv ua haujlwm tau zoo thiab txhua tus haum rau kuv lub microcontroller. Nws siv ob peb hmo los ua kom tiav thiab txhua yam mus tau zoo … txog thaum kuv tau sim muab lawv ua ke hauv cov lus hloov pauv. avr-qhov muaj txiaj ntsig tau tshaj tawm 1.5 Kb ntu ntu ntawv (nrog -s chij ntawm avr-gcc). Lub sijhawm ntawd kuv thawj lub hom phiaj yog kom tau txais qee qhov ATtiny25 nrog 2Kb nyem thiab qhov ntawd tuaj yeem yog qhov zoo siab kawg ntawm zaj dab neeg no.
Tab sis qee qhov kuv xav tias tom qab txiav txim siab qhov ua tau zoo kuv tuaj yeem tswj hwm kom txo qis qhov kev ua phem rau hauv 1Kb. Txawm li cas los xij, nws siv sijhawm ib lub lim tiam ntxiv kom paub tias nws tsis yooj yim sua thiab ib lub lim tiam ntxiv los ua kom tiav. Kuv yuav tsum tau txiav tus zaj sawv rau tsib xim yooj yim (tsis muaj qhov sib txawv qhov muag pom). Kuv tau tshem ntawm cov ntaub ntawv cov ntaub ntawv thiab siv cov saw ntawm yog-ces-yog kom txo qis binary code loj. Kev tua hluav taws xav tau pseudorandom tus lej hluav taws xob uas loj heev, yog li kuv tau siv qhov yooj yim ntawm LFSR nrog tus nqi pib tas li. Kuv tsis quav ntsej txog PRNG tag nrho lub voj voog ntev thiab tsuas yog nrhiav qhov sib npaug ntawm qhov loj me me thiab "qhov hluav taws kub tiag tiag". Kuv kuj tau siv ntau qhov kev txhim kho me me kuv tsis tuaj yeem nco tau tam sim no thiab txawm tias tswj tau nyem txhua txoj kev sib nrug ntawm hluav taws mus rau hauv lub nti. Thaum kuv khiav tawm ntawm cov tswv yim, kuv cov lej tag nrho yog txog 1200 bytes.
Kuv siv sijhawm tas sijhawm thiab tau nyeem ntau txog AVR txoj cai kom zoo. Kuv tau nyob ze rau kev tso tseg thiab rov sau txhua yam hauv cov lus sib dhos tab sis muab nws zaum kawg. Thaum lub sijhawm ua tiav qhov ua tiav zaum kawg, Kuv tau txiav tus zaj sawv rau peb qhov xim yooj yim thiab ua rau lwm tus los suav rau ntawm yoov, Kuv tshuaj xyuas txhua yam thiab ua raws AVR qhov kev pom zoo thiab thaum kawg …
avrdude: sau flash (1004 bytes):
Sau ntawv | ############################################# | 100% 0.90s
Tsis tas yuav hais tias kuv siv yuav luag tag nrho RAM thiab tsuas yog ib byte ntawm EEPROM khaws cia hom tam sim no. Kuv tsis hais tias qhov no yog qhov zoo tshaj plaws thiab ua tiav qhov kawg. Nws tsuas yog ua haujlwm thiab haum rau microcontroller. Kuv paub tseeb, koj tuaj yeem ua nws zoo dua. Kuv yeej yog. Kuv tsuas yog xav qhia qhov kev lom zem ntawm kev daws teeb meem uas pom tsis tau uas koj xav tias yuav luag tsis yooj yim sua thaum pib. "Yog li, nyiag nkas txhais tau tias tshawb txog qhov txwv ntawm qhov ua tau …" -Richard Stallman.
Khoom siv:
1x ATtiny13 MCU ($ 0.28 = $ 0.24 rau MCU hauv SOP-8 pob thiab $ 0.04 rau DIP8 Adapter)
8x WS2812 RGB LEDs (Kuv pom zoo rau pawg thawj coj lossis ib daim ntawm LED kab txaij) ($ 0.42)
1x TTP223 Kov khawm ($ 0.10)
1x Micro USB rau DIP Adapter ($ 0.14)
1 x 10kΩ resistor (<$ 0.01)
1x 100nF ceramic capacitor (<$ 0.01)
1x 10–47µF electrolytic capacitor (<$ 0.01)
Tag nrho <$ 0.97
Kauj ruam 1: Teeb Software
Koj yuav xav tau avr-gcc toolchain rau suav sau qhov chaws thiab avrdude nqi hluav taws xob rau kev xa cov microcontroller's ROM. Cov txheej txheem teeb tsa yog yooj yim zoo nkauj thiab yooj yim, tab sis nws nyob ntawm koj lub operating system. Yog tias koj siv qee yam ntawm GNU/Linux, tej zaum koj twb muaj cov pob tsim nyog hauv koj lub chaw cia khoom. Qhov chaws ntawm txoj haujlwm no tuaj yeem rub tawm ntawm no:
github.com/arduinocelentano/t13_ws2812_lamp
Koj tseem yuav xav tau lub tsev qiv ntawv light_ws2812:
github.com/cpldcpu/light_ws2812
Thaum koj tau txais avr-gcc toolchain thiab cov phiaj xwm phiaj xwm, khiav koj lub davhlau ya nyob twg thiab ntaus cov cai hauv qab no:
cd txoj kev/rau/qhov project
ua
Kauj Ruam 2: Programming Microcontroller
Yog tias koj muaj qee yam ntawm USBASP programmer, tsuas yog txuas nws mus rau Attiny raws li nws qhov pinout. Feem ntau nws yuav zoo li qhov no tab sis kuv pom zoo kom txheeb xyuas koj tus pinout tiag!
Xwb, koj tuaj yeem siv Arduino board ua tus programmer. Qhib Arduino IDE thiab nrhiav Arduino ISP piv txwv hauv "Cov Ntaub Ntawv → Piv Txwv" ntawv qhia zaub mov. Tom qab xa cov duab kos, koj pawg thawj coj Arduino ua tus programmer. Cov lus pom hauv kab lus kos duab yuav ua rau koj paub qhov pinout.
Tam sim no khiav
ua flash
kom nyem MCU thiab
ua fuse
teeb fuse khoom.
Pom zoo:
Nyeem thiab Teeb Duab Lub Teeb thiab Kub Sensor Cov Ntaub Ntawv Nrog Raspberry Pi: 5 Cov Kauj Ruam
Nyeem thiab Teeb Duab Lub Teeb thiab Kub Sensor Cov Ntaub Ntawv Nrog Raspberry Pi: Hauv Cov Lus Qhia no koj yuav kawm paub yuav nyeem lub teeb thiab ntsuas kub li cas nrog raspberry pi thiab ADS1115 analog rau cov hloov pauv thiab teeb nws siv matplotlib. Cia pib nrog cov ntaub ntawv xav tau
DIY LED Teeb - Niaj Hnub Teeb Meem Teeb Nrog Cov Chaw Taws Teeb: 8 Kauj Ruam (nrog Duab)
DIY LED Teeb - Niaj Hnub Teeb Mood Teeb Nrog Chaw Taws Teeb: Hauv kab lus no kuv yuav mus hla cov txheej txheem Kuv tau siv los tsim qhov no zoo heev pyramid zoo li tus LED Mood Teeb.Kuv siv maple rau cov qauv tseem ceeb thiab qee qhov mahogany txhav ntxiv rau lub zog. Rau lub teeb Kuv siv RGB LED teeb uas tuaj nyob hauv 16 ko taw
8 Relay Tswj Nrog NodeMCU thiab IR Txais Txais Siv WiFi thiab IR Chaw Taws Teeb thiab Android App: 5 Kauj Ruam (nrog Duab)
8 Relay Tswj Nrog NodeMCU thiab IR Txais Txais Siv WiFi thiab IR Chaw Taws Teeb thiab Android App: Tswj 8 qhov hloov pauv hloov siv nodemcu thiab ir tus txais tshaj wifi thiab ir chaw taws teeb thiab hauv app.the ir tej thaj chaw deb ua haujlwm ywj pheej ntawm wifi txuas. NTUJ
LED Teeb Teeb Duab Cwjmem: Cov Cuab Yeej rau Teeb Teeb Doodles: 6 Kauj Ruam (nrog Duab)
LED Teeb Teeb Lub Cwjmem: Cov Cuab Yeej rau Teeb Doodles: Kuv tus poj niam Lori yog tus neeg siv tsis tu ncua thiab kuv tau ua si nrog kev yees duab ntev ntev rau ntau xyoo. Kev tshoov siab los ntawm PikaPika pab pawg teeb pom kev zoo thiab yooj yim ntawm cov koob yees duab digital peb tau siv lub teeb duab kos duab kom pom tias peb tuaj yeem ua dab tsi
Cov Roj Teeb Lemon Me, thiab Lwm Cov Qauv rau Xoom Tus Nqi Hluav Taws Xob thiab Coj Lub Teeb Tsis Muaj Roj Teeb: 18 Kauj Ruam (nrog Duab)
Cov Roj Teeb Lemon Me, thiab Lwm Cov Qauv rau Xoom Tus Nqi Hluav Taws Xob thiab Coj Lub Teeb Tsis Muaj Roj Teeb: Nyob zoo, tej zaum koj twb paub txog txiv qaub roj teeb lossis roj teeb roj teeb. Lawv tau siv ib txwm siv rau lub hom phiaj kev kawm thiab lawv siv cov tshuaj tiv thaiv hluav taws xob uas tsim hluav taws xob qis, feem ntau pom nyob rau hauv daim ntawv ntawm cov coj lossis lub teeb ci ci. Cov no