Cov txheej txheem:
- Kauj Ruam 1: Cov Ntaub Ntawv thiab Kev Txhim Kho
- Kauj Ruam 2: Soldering AVR rau LEDs thiab Tus Hais Lus
- Kauj Ruam 3: Programming Attiny13a
- Kauj Ruam 4: Tsim Firmware rau Marioman
- Kauj Ruam 5: Tso Marioman Xoob
Video: Kev ntsais muag, Hu nkauj, Marioman: 5 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:31
Siv qhov attiny13a, ob lub LEDs thiab daim npav tos txais tus neeg hais lus kom tsim lub ntsais muag Marioman uas ua yeeb yaj kiab Super Mario Brothers ntsiab nkauj zaj nkauj. Qhov no tuaj yeem yog txoj haujlwm yooj yim-tus nqi qis rau txhua tus neeg uas tab tom nrhiav txoj hauv kev lom zem kom tawg mus rau hauv AVR txoj haujlwm! sau ntawv ntawm cov nkauj tau tsim los ntawm ib puag ncig nthwv dej tso tawm ntawm ib tus pin ntawm AVR microcontroller. Cov LEDs uas hloov pauv ntawm txhua daim ntawv tau txuas nrog 2 tus pin ntawm txhua tus tib lub nti.
Kauj Ruam 1: Cov Ntaub Ntawv thiab Kev Txhim Kho
1 qig 13a
www.mouser.com/Search/ProductDetail.aspx?qs=sGAEpiMZZMvu0Nwh4cA1wRKJzS2Lmyk%252bEP0e%2f7dEeq0%3dCost: $ 1.40
- 2 LEDs - ib qho LEDs yuav ua
- 1 lithium npib cell roj teeb
www.sparkfun.com/commerce/product_info.php?products_id=338 Tus nqi: $ 2.00
1 npib cell tuav
www.sparkfun.com/commerce/product_info.php?products_id=8822Cost: $ 1.25
1 tus neeg hais lus me me los ntawm daim npav tos txais suab paj nruag
Tag nrho tus nqi ntawm cov ntaub ntawv ~ $ 5 Ob lub LEDs tau txuas ncaj qha rau ob tus pin ntawm txhua qhov attiny13A. Ob tus pin tau siv rau txhua tus LED, tus pin thib ob tau teeb tsa qis kom siv los ua kev sib txuas hauv av. Qhov txwv tam sim no ntawm I/O pins ntawm AVR yuav tiv thaiv cov LED los ntawm kev kos ntau dhau yog li tus tiv thaiv tsis tas yuav txuas rau hauv koob. Tus neeg hais lus siv yog qhov ib txwm pom hauv daim npav tos txais suab paj nruag, txhua tus neeg hais lus me me yuav ua, muab qhov no tso tawm lub suab yoj plaub fab, nws tsis tseem ceeb heev rau kev txhawj xeeb txog kev tsav tus hais lus lossis lub suab zoo.
Kauj Ruam 2: Soldering AVR rau LEDs thiab Tus Hais Lus
Rau cov LEDs mus ncav tes zoo li caj npab ib tus pin tau khoov ntawm AVR txhua sab. Kev taw qhia AVR txoj hauv kev no ua rau nws yooj yim los txuas rau tus hais lus (duab thib ob) txij li kev sib txuas yog nyob rau ntawm ob sab hauv qab. nws yog txuas.
Kauj Ruam 3: Programming Attiny13a
Muaj ntau qhov kev xaiv sib txawv rau cov phiaj xwm AVRs rau txoj haujlwm no USBtiny tau siv uas muaj cov khoom siv los ntawm ladyada lub vev xaib https://www.ladyada.net/make/usbtinyisp/index.html Txhawm rau txuas AVR rau tus programmer koj tuaj yeem ob qho txuas cov xov hluav taws xob rau tus poj niam lub qhov (socket) thiab ntsaws lawv rau hauv lub khob cij lossis zoo dua tseem tau txais AVR cov phiaj xwm pheej yig zoo li qhov no.
Kauj Ruam 4: Tsim Firmware rau Marioman
Cov attiny13A muaj 1K ntawm qhov programmable flash, thiab 64bytes ntawm SRAM. Cov ntaub ntawv txuas nrog tar muaj cov ntaub ntawv nrog rau kev suav sau cov firmware rau rub tawm.
- freq - zaus ntawm txhua daim ntawv
- ntev - ntev ntawm txhua daim ntawv
- ncua - ncua ntawm txhua daim ntawv
Qhov ntau zaus tsis muaj qhov ntau zaus tab sis zoo dua tus nqi tso rau hauv TTCROB sau npe los tsim lub xwmfab yoj tawm ntawm PB0 tus pin. Ntawm no yog cov ntsiab lus luv luv ntawm kev suav thiab tus pin teeb tsa rau cov xwm txheej yoj tiam:
- Attiny13A muaj cov oscillator sab hauv teeb tsa rau 9.6MHz
- Lub moos sab hauv rau IO yog oscillator faib los ntawm 8 lossis 1.2MHz
- Tus timer sab hauv tau teeb tsa hauv 8 tus lej rau npe kom suav txhua lub voj voog nrog prescale ntawm 8.
- Qhov no tshwm sim hauv ib qho zuam sib npaug rau 1 / (1.2MHz / 8) =.006667ms
- Attiny13A tau teeb tsa los sib piv dab tsi hauv 8bit TCCR0B sau npe nrog lub sijhawm thiab hloov tus pin thaum lawv sib phim.
- Piv txwv li, txhawm rau tsim kom muaj lub voos xwmfab ntawm 524Hz (ib lub octave saum nruab nrab C) uas muaj lub sijhawm 1.908ms.
1.908ms = 286 moos zuam (1.908/.0067) Faib 286 los ntawm 2 toggle tus pin ntawm t/2 (286/2 = 143) Muab 143 rau hauv TTCR0B sau npe los tsim daim ntawv no. Qhov no yog txhua txoj cai uas tsim nyog los teeb tsa lub sijhawm, ua qhov sib piv thiab tso tawm ib puag ncig yoj:
TCCR0A | = (1 << WGM01); // teeb tsa timer 1 rau CTC hom TCCR0A | = (1 << COM0A0); // toggle OC0A ntawm kev sib piv sib tw TCCR0B | = (1 << CS01); // clk/8 prescale TTCR0B = 143; // tsim cov xwm txheej yoj ntawm 524HzTxhawm rau ncua lub suab nrov thiab ncua ntawm lawv ib qho yooj yim ncua kev ua haujlwm tau siv
pw tsis tsaug zog (int ms) {int cnt; rau (cnt = 0; cnt <(ms); cnt ++) {int kuv = 150; thaum (i--) {_asm ("NOP"); }}}Qhov no suav los ntawm 150 qhov twg txhua lub NOP lub voj voog yog kwv yees li.006667ms. Qhov kawg qhov chaws ua yog hla ntawm cov kab, tsim cov nkauj thiab ntsais ob lub LEDs. Qhov no ua tiav txuas ntxiv rau lub voj nrog cov cai hauv qab no
const uint8_t freq PROGMEM = {… data}; const uint8_t ntev PROGMEM = {… data}; const uint8_t ncua PROGMEM = {… data};… thaum (1) {rau (cnt = 0; cnt < 156; cnt ++) {OCR0A = pgm_read_byte (& freq [cnt]); output_toggle (PORTB, PB3); output_toggle (PORTB, PB4); pw tsaug zog (pgm_read_byte (& ntev [cnt])); output_toggle (PORTB, PB3); output_toggle (PORTB, PB4); // nres timer TCCR0B = 0; pw tsaug zog (pgm_read_word (& ncua [cnt])); // pib timer TCCR0B | = (1 << CS01); // clk/8 prescale}}Muaj 156 cov ntsiab lus hauv qhov zaus/ntev/ncua arrays, lub voj no hla lawv. Pin PB3 thiab PB4 yog txhua tus toggled yog li lawv yuav hloov pauv nrog txhua qhov ceeb toom Thawj qhov pw tsaug zog yog qhov ntev ntawm daim ntawv peb ua si tom qab teeb tsa OCR0A rau tus nqi tsim nyog. Qhov kev pw tsaug zog thib ob yog ncua ntawm cov ntawv peb ua si. Hauv cov cai saum toj no koj yuav tau pom ob lub luag haujlwm pgm_read_byte () thiab pgm_read_word () ntxiv rau lo lus tseem ceeb PROGMEM. With nrog cov ntiv tes kos zoo li attiny tus nqi ntawm SRAM tsawg heev, qhov no tsuas yog 64bytes. Cov kab ntawv peb tab tom siv rau txhua qhov ntawm cov zaus/ncua/ntev cov ntaub ntawv loj dua 64bytes thiab yog li ntawd tsis tuaj yeem thauj khoom mus rau lub cim xeeb. Los ntawm kev siv qhov tshwj xeeb PROGMEM avr-gcc cov lus qhia cov ntaub ntawv loj no tau tiv thaiv los ntawm kev nkag mus rau hauv lub cim xeeb, hloov lawv tau nyeem los ntawm nyem.
Kauj Ruam 5: Tso Marioman Xoob
Cov vis dis aus saum toj no qhia Marioman hauv kev nqis tes ua. Qhov nruab nrab siv hluav taws xob yog kwv yees li 25mA yog li nws tuaj yeem ntsais thiab ua suab nrov txog li 10 teev ua ntej tso lub lithium npib ntawm tes. Qhov tsuas yog txoj hauv kev los txhawb nws rau thiab tawm yog tshem tawm cov npib ntawm cov roj teeb, qhov ruaj khov uas tau teev tseg hauv cov ntaub ntawv yog zoo haum rau qhov no. Hloov tau ntxiv tau tab sis muaj qee yam yuav tsum tau hais kom ua kom yooj yim.
Pom zoo:
Lub Ntsej Muag Ntsej Muag Ntsej Muag => Covid Tiv Thaiv!: 5 Kauj Ruam
Lub Ntsej Muag Ntsej Muag Ntsej Muag => Covid Tiv Thaiv!: Tus naj npawb 1 yam uas cov neeg saib xyuas kev noj qab haus huv xav kom tib neeg ua thaum lub sijhawm muaj tus kabmob kis no yog hnav lub ntsej muag thaum tawm mus rau qhov chaw pej xeem, tab sis qee tus neeg tseem ua qhov muag tsis pom qhov lus ceeb toom. Nkag mus ….. COVID PrevEnter! Tus neeg hlau no siv lub koob yees duab Pixy2
LED ntsais muag {khawm tswj}: 5 Cov kauj ruam
LED ntsais muag {khawm tswj}: Kuv yog menyuam kawm ntawv hauv Kang Chiao. Nov yog kuv qhov haujlwm, Kuv siv Arduino thiab ua lub teeb ci-ntsais nrog lub pob uas tuaj yeem ua rau nws ntsais. Koj tuaj yeem muab nws tso rau ntawm koj daim ntaub thiab thaum qee tus neeg nyob ze koj, koj tuaj yeem nias lub pob thiab lub teeb ci wi
Halloween Project Nrog Pob txha taub hau, Arduino, LED ntsais thiab ntsais muag qhov muag - Maker, MakerED, MakerSpaces: 4 Kauj Ruam
Halloween Project Nrog Pob txha taub hau, Arduino, LED ntsais thiab ntsais muag qhov muag | Tsim, Ua, MakerSpaces: Halloween Project nrog pob txha taub hau, Arduino, ntsais muag LEDs thiab Scrolling EyesSoon yog Xus, yog li cia peb tsim qhov project txaus ntshai thaum coding thiab DIY (tinkering me ntsis …). Cov ntawv qhia no yog ua rau cov neeg uas tsis muaj 3D-Tshuab Luam Ntawv, peb yuav siv 21 cm plas
Qhov Muag Qhov Muag Pw Tsaug Suab Nkauj: 5 Kauj Ruam
Qhov Muag Qhov Muag Pw Tsaug Suab Nkauj: Nov yog txoj haujlwm tso cai rau koj pw tsaug zog zoo thaum hmo ntuj, tso siab rau qhov qeeb nkauj Christmas nkauj ntawm daim npog qhov muag
LED qhov muag ntsais rau neeg hlau: 6 Kauj Ruam
LED Qhov Muag Blinking rau Neeg Hlau: Phau ntawv qhia no yog hais txog Kev ntsais muag ntawm qhov muag ntawm Neeg Hlau siv LED dot matrix