Cov txheej txheem:

Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812: 7 Cov Kauj Ruam
Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812: 7 Cov Kauj Ruam

Video: Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812: 7 Cov Kauj Ruam

Video: Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812: 7 Cov Kauj Ruam
Video: Lub Zog Nruab Nrog (Hmong Dubbed) 2024, Kaum ib hlis
Anonim
Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812
Ib $ 1 LED Mood Teeb Nrog ATtiny13 thiab WS2812

Los ntawm arduinocelentanoFollow Ntxiv los ntawm tus sau:

Tus Kheej CalDAV Server ntawm Ib Leeg Computer
Tus Kheej CalDAV Server ntawm Ib Leeg Computer
Tus Kheej CalDAV Server ntawm Ib Leeg Computer
Tus Kheej CalDAV Server ntawm Ib Leeg Computer
LCD Invaders: Qhov Chaw Invaders Zoo Li Kev Ua Si ntawm 16x2 LCD Cov Cim Cim
LCD Invaders: Qhov Chaw Invaders Zoo Li Kev Ua Si ntawm 16x2 LCD Cov Cim Cim
LCD Invaders: Qhov Chaw Invaders Zoo Li Kev Ua Si ntawm 16x2 LCD Cov Cim Cim
LCD Invaders: Qhov Chaw Invaders Zoo Li Kev Ua Si ntawm 16x2 LCD Cov Cim Cim
Octarine: Kev Sib Tw Xim Xim nrog WS2812 RGB LEDs
Octarine: Kev Sib Tw Xim Xim nrog WS2812 RGB LEDs
Octarine: Kev Sib Tw Xim Xim nrog WS2812 RGB LEDs
Octarine: Kev Sib Tw Xim Xim nrog WS2812 RGB LEDs

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

Teeb Software
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

Programming Microcontroller
Programming Microcontroller
Programming Microcontroller
Programming Microcontroller
Programming Microcontroller
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: