Cov txheej txheem:

Snake on a Breadboard: 3 Kauj Ruam (nrog Duab)
Snake on a Breadboard: 3 Kauj Ruam (nrog Duab)

Video: Snake on a Breadboard: 3 Kauj Ruam (nrog Duab)

Video: Snake on a Breadboard: 3 Kauj Ruam (nrog Duab)
Video: Snake! on my Ben Eater inspired 8-bit breadboard computer (source code and emulator available) 2024, Hlis ntuj nqeg
Anonim
Nab ntawm Breadboard
Nab ntawm Breadboard
Nab ntawm Breadboard
Nab ntawm Breadboard
Nab ntawm Breadboard
Nab ntawm Breadboard

"Tau txais kev ua si hauv koj lub xov tooj?"

"Tsis yog raws nraim."

Qhia:

Yooj yim los tswj, yooj yim rau txoj haujlwm, thiab tsis txawj tuag los ntawm Nokia 6110, Snake tau dhau los ua txoj haujlwm nyiam ntawm cov kws tsim khoom. Nws tau ua tiav hauv ib yam dab tsi los ntawm LED qib, LCDs, teeb pom kev hauv phau ntawv, thiab txawm tias qhov rais ntawm txhua lub tsev. Peb yuav tau siv Snake ntawm lub khob cij me me thiab lub vijtsam OLED. Tib neeg yeej tau ua tinier cov neeg ua si nab, tab sis qhov no tshwj xeeb yog siv lub khob cij, tshem qhov xav tau los tsim PCBs lossis cov laug.

(Koj tuaj yeem tsuas yog ua daim ntawv thov ntawm koj lub xov tooj, tab sis peb tsis ua qee yam vim tias lawv yooj yim.)

Yam yuavtsum tau kawm uantej:

Kev nkag siab yooj yim ntawm cov kab hluav taws xob, yuav ua li cas rau mov ci, thiab nkag siab zoo ntawm cov phiaj xwm hauv Arduino.

Khoom siv

  • Arduino Nano Cov
  • 2 tsim nyog siab resistors (1kOhm)
  • Cov ntawv me me
  • 2 Pushbuttons
  • 22 AWG cov tub ntxhais hlau
  • 128 x 64 OLED

Cov no yog Amazon cov koom tes txuas mus yog li kuv tau khwv tau nyiaj me ntsis nrog txhua qhov muag. Yog tias koj tsis muaj cov khoom siv no thiab xav txhawb nqa cov phiaj xwm yav tom ntej ntawm kuv, ua raws cov kab ntawv txuas no!:)

Kauj ruam 1: Breadboard

Cov qhob cij
Cov qhob cij
Cov qhob cij
Cov qhob cij
Cov qhob cij
Cov qhob cij

Txhawm rau ua peb cov khoom kawg, peb pom tseeb yuav tsum sib sau cov cuab yeej khoos phis tawj thiab sim peb txoj haujlwm. Cov kab ke kab ke rau txoj haujlwm no yooj yim haum, vim nws tsuas yog koom nrog tag nrho ntawm 4 yam.

1. Ua nws tawm:

Nqa koj cov khoom thiab teeb lawv tawm ntawm lub rooj tsavxwm, kom ntseeg tau tias txhua yam haum. Pom kev pom cov xov hlau thiab tus pin koj yuav siv thiab rau lub hom phiaj twg. Nco ntsoov tias koj cov xov hlau xav tias yuav tsis hla, vim qhov ntawd ua rau lub khob cij tsis zoo. Sau cov ntsiab lus twg koj yuav xav tau txuas! Txawm hais tias qhov no yog daim ntawv qhia zaub mov yooj yim, nws yuav ua rau koj lub neej yooj yim dua thaum lub sijhawm txheej txheem thiab feem ntau. Vim tias peb qhov chaw ua haujlwm me me li cas, qhov no yog kauj ruam tseem ceeb kawg.

Sau ntawv:

Vim tias OLED siv I2C npav, tus pin A4 thiab A5 yuav tsum tau siv. Qhov loj ntawm daim ntawv qhia zaub mov tsis tso cai rau lub zog thiab cov tsheb nqaj hlau hauv av, yog li kuv tau siv qee qhov kev dag ntxias kom txhua yam ua haujlwm tau zoo. Qhov ntsuas hluav taws xob zoo rau cov nyees khawm tau muab los ntawm pins D13 thiab A2. Kuv pom tias Arduino pins tuaj yeem tsis tsuas yog muab cov khoom siv tam sim no, tab sis tso dej tam sim no ib yam, yog li kuv siv A3 ua qhov av rau khawm raug. Txhawm rau kom qhov chaw nyob ntau tshaj plaws ntawm daim ntawv qhia zaub mov, kuv tau dai ib nrab ntawm Nano tawm ntawm lub rooj tsavxwm thiab txhawb nqa sab laug pins nrog ib daim ua npuas ncauj.

2. Siv nws tawm:

Nrog ib khub ntawm cov hlua hlau thiab tus nqi tsim nyog ntawm 22 AWG cov tub ntxhais hlau, ua tib zoo xaim koj cov khoom ua ke. Siv cov tub ntxhais khov kho los ua cov phiaj ib lub khob cij tas mus li yog qhov tseem ceeb, vim tias koj tuaj yeem txiav lawv kom ntev, tsis zoo li cov xov hluav taws xob. Nco ntsoov tias koj tsis tso ntau qhov ntev dhau ntawm koj cov xov hlau, nws yuav ua rau pawg thawj coj tsis sib haum. Txiav cov kab ntawm cov rub tawm cov neeg tawm tsam kom lawv haum yaug nrog lub rooj tsavxwm.

(Koj tseem tuaj yeem ua raws li qhov kuv tau ua saum toj no.)

Kauj Ruam 2: Txoj Haujlwm thiab Kev Xeem

Txoj Haujlwm thiab Kev Xeem
Txoj Haujlwm thiab Kev Xeem

Txhawm rau txuag koj tus kheej mob taub hau tom qab, xyuas kom tseeb tias OLED thiab cov nyees khawm ua haujlwm raws li lawv xav tau los ntawm kev ua cov phiaj xwm xeem.

1. Npaj, npaj, npaj:

Tsuas yog dhia txoj cai rau hauv txoj cai tsis yog kev xyaum ntse. Ntseeg kuv, kuv tau sim! Tias yog vim li cas koj yuav tsum piav qhia tias koj qhov program yuav ua haujlwm li cas. Cov phiaj xwm kev khiav haujlwm yog txoj hauv kev zoo nkauj los npaj tawm qhov koj tus lej yuav tsum tau ua thiab yuav ua kom koj taug qab. Coj kuv tus piv txwv (saum toj no)

2. Code, code, chaws:

Qhov tseeb, txoj haujlwm no yog kev ua haujlwm loj dua li nws yog kev ua haujlwm kho vajtse. Tsuas yog lub tsev qiv ntawv kuv siv yog Adafruit lub tsev qiv ntawv OLED, tsis suav nrog txhawb nqa GFX thiab Cov tsev qiv ntawv hlau.

Ua rau koj nruab Adafruit lub tsev qiv ntawv OLED ntawm Arduino IDE tus thawj tswj tsev qiv ntawv.

Kuv tsis tuaj yeem sau txhua kab ntawm tus lej kuv tau sau, tab sis ntawm no yog ob peb lub tswv yim:

Lub tswv yim:

Lus:

- Ua ntej tshaj plaws, sau cov lus pom zoo thiab muaj txiaj ntsig thaum koj ua tus lej. Yav tom ntej koj thiab lwm tus uas nyeem koj cov cai yuav ua tsaug rau koj.

Nco:

- Nrog cov phiaj xwm nyuaj dua li cov no, SRAM dhau los ua cov khoom lag luam kub. Hauv Adafruit lub tsev qiv ntawv, 128 x 64 OLED tsis siv sijhawm 1 kB ib leeg, uas yog kwv yees li ib nrab ntawm lub cim xeeb hauv ATMega328p. Yog li kev tswj hwm lub cim xeeb ntse tseem ceeb dua li yav tas los.

- Nrog cov ntaub ntawv loj, cov ntaub ntawv tuav yuav sib sau ua ke thiab siv ntau qhov chaw. Txhawm rau txo qhov cim xeeb hneev taw ntawm kuv qhov hloov pauv, Kuv siv cov ntaub ntawv me me (zoo li luv thiab byte) thaum kuv tuaj yeem ua tau.

- Cov hlua feem ntau khaws cia hauv SRAM, tab sis siv F () ua haujlwm yuav muab lawv tso rau hauv PROGMEM xwb, txuag kev nco zoo.

Millis:

- Txhawm rau ua tiav lub sijhawm kom raug dua ntawm kev ua si, siv millis () ua haujlwm. Muaj ntau ntau cov kev qhia zoo thiab piv txwv online.

Ua ntej txhais:

- Siv #define preprocessor directive raws li txoj hauv kev yooj yim los teeb tsa qhov tseem ceeb hauv cov cai.

Xeem:

- Xeem koj cov cai thaum koj mus. Nws yuav yooj yim dua rau tshem tawm cov kab.

Kauj ruam 3: Txaus siab rau

Muaj kev lom zem nrog koj qhov kev ua si nab tshiab!

(Kuv paub tias kuv yeej ntawm 20 cov ntsiab lus hauv cov vis dis aus saum toj no, koj tuaj yeem teeb tsa qhov kev yeej zoo dua hauv kuv tus lej.)

Yam yuav nthuav dav rau:

  • Roj teeb rau nqa tau
  • Cov nyees khawm ruaj ntseg dua
  • Ib qhov kev ua si nab me dua
  • Txawm tias ua si ntau dua?

Pom zoo: