Cov txheej txheem:

FaceBot: 8 Kauj Ruam
FaceBot: 8 Kauj Ruam

Video: FaceBot: 8 Kauj Ruam

Video: FaceBot: 8 Kauj Ruam
Video: Plab Plab Ntswg..(Pluav Pluav Ntswg) Maiv Twm New Song 2023-2024 2024, Kaum ib hlis
Anonim
FaceBot
FaceBot

Phau ntawv qhia no yuav qhia koj yuav ua li cas tsim tus nqi qis ($ 39) kev sib tsoo kom tsis txhob muaj neeg hlau nrog lub ntsej muag ntawm tus tsiaj ntawv. Peb ua qhov no los ntawm kev siv tus nqi qis tshiab, ci ci OLED zaub. Peb cov tub ntxhais kawm nyiam ntxiv lub ntsej muag rau lawv cov neeg hlau. Lawv nyiam kos ntsej muag luag ntxhi uas hloov pauv raws li tus neeg hlau ua.

Muaj ntau ntau tus neeg hlau tus nqi me me muaj rau qis dua $ 25 uas tso cai rau koj qhia qhov pib ntawm computer science. Ib qho ntawm cov teeb meem nrog cov neeg hlau no yog lawv tsis muab kev pom zoo raws li dab tsi tshwm sim hauv tus neeg hlau thaum koj tab tom tsim nws. Xyoo 2018 uas txhua tus pib hloov pauv nrog qhov muaj cov nqi qis zoo OLED cov lus. Cov lus qhia no muaj cov txiaj ntsig hauv qab no:

  • Lawv ci heev thiab muaj qhov sib txawv siab. Txawm tias chav ci ci lawv yooj yim nyeem los ntawm ntau lub ces kaum.
  • Lawv muaj kev daws teeb meem zoo. Cov uas kuv siv yog 168x64 pixels. Qhov no yuav luag 4x cov lus qhia ua ntej uas peb tau siv.
  • Lawv muaj lub zog qis thiab lawv ua haujlwm tsis tu ncua txawm tias thaum koj tus neeg hlau lub zog poob qis.
  • Lawv yog tus nqi qis (ib ncig $ 16 txhua) thiab tus nqi poob qis.

Yav dhau los, lawv tau nyuaj rau program thiab yuav siv ntau lub cim xeeb los siv nrog tus nqi qis Arduino Nanos. Nano tsuas muaj 2K lossis muaj zog RAM. Phau ntawv qhia no yuav qhia koj yuav ua li cas tiv thaiv cov teeb meem no thiab tsim cov neeg hlau uas cov menyuam nyiam ua haujlwm.

Kauj Ruam 1: Kauj Ruam 1: Tsim Koj Lub Hauv Paus Neeg Hlau

Kauj Ruam 1: Tsim Koj Lub Hauv Paus Neeg Hlau
Kauj Ruam 1: Tsim Koj Lub Hauv Paus Neeg Hlau

Txhawm rau tsim FaceBot peb ib txwm pib nrog lub hauv paus neeg hlau. Ib qho piv txwv yog $ 25 CoderDojo Robot uas tau piav qhia ntawm no. Tus neeg hlau no siv tus nqi qis thiab nrov Arduino Nano, tus tswj lub cev yooj yim, 2 DC-motors thiab 4 lossis 6 AA roj teeb. Cov tub ntxhais kawm feem ntau pib siv lub ping sensor los tsim kev sib tsoo kom tsis txhob muaj neeg hlau. Vim tias nws muab lub zog 5v nws yog qhov zoo tshaj plaws rau FaceBot. Txhawm rau kom tus nqi qis Kuv feem ntau muaj kuv cov tub ntxhais kawm xaj cov khoom online ntawm e-Bay. Cov ntu feem ntau siv sijhawm 2-3 lub lis piam los txog thiab xav tau ib qho me me ntawm cov tshuaj txhuam rau lub cav thiab hloov lub zog. Qhov seem ntawm kev sib txuas tau tsim los siv 400-khi qhob cij. Cov tub ntxhais kawm nquag nquag kub-lo cov xov hlau kom lawv tsis txhob plam tawm.

Muaj ib qho kev hloov pauv uas peb ua rau tus qauv kev sib tsoo zam kev tsim qauv. Peb txav lub ping sensor los ntawm sab saum toj ntawm lub chassis mus rau hauv qab lub chassis. Qhov no tawm hauv chav rau cov zaub nyob saum cov neeg hlau.

Thaum koj muaj koj li kev sib tsoo zam kev ua haujlwm koj tau nyeem ntxiv lub ntsej muag!

Kauj Ruam 2: Kauj Ruam 2: Nrhiav thiab xaj Koj Cov Zaub OLED

Kauj Ruam 2: Nrhiav thiab xaj Koj Cov Zaub OLED
Kauj Ruam 2: Nrhiav thiab xaj Koj Cov Zaub OLED

Thaum OLED cov lus nthuav tawm, tus nqi qis tau tsim los rau saib lossis saib xyuas lub cev. Raws li qhov tshwm sim lawv tau me me, feem ntau nyob ib ncig ntawm 1 ntiv tes hla. Cov xov xwm zoo yog lawv tau them tus nqi qis, ib puag ncig $ 3. Peb tau tsim ob peb tus neeg hlau nrog cov lus qhia no, tab sis vim tias qhov loj me ntawm cov lus tau raug txwv yam peb tuaj yeem ua ntawm lub vijtsam. Tom qab ntawd xyoo 2018 peb pib pom tus nqi loj dua 2.42 nti OLED cov ntxaij vab tshaus nqis los. Thaum Lub Ib Hlis xyoo 2019 tus nqi tau nqis txog $ 16. Thaum kawg peb muaj cov khoom zoo uas peb tuaj yeem siv rau peb lub ntsej muag neeg hlau.

Nov yog qhov tshwj xeeb ntawm cov lus qhia no:

  1. 2.42 nti (ntsuas kab pheeb ces kaum)
  2. 128 pixels thoob plaws (x-dimension)
  3. 64 pixels siab (y-dimension)
  4. Lub zog qis (feem ntau 10ma)
  5. Monochrome (lawv tuaj hauv daj, ntsuab, xiav thiab dawb)
  6. Default SPI interface txawm hais tias koj tuaj yeem hloov nws mus rau I2C yog tias koj xav tau
  7. SSD1309 tus tsav tsheb (tus tsav tsheb pom zoo heev)

SPI interface muaj xya lub xov hlau. Nov yog cov ntawv cim raug ntawm lub interface:

  1. CS - Chip Xaiv
  2. DC - Cov Ntaub Ntawv/Hais Kom Ua
  3. RES - Pib dua
  4. SDA - Cov ntaub ntawv - qhov no yuav tsum txuas nrog Arduino Nano tus pin 11
  5. SCL - Clock - qhov no yuav tsum txuas nrog Arduino Nano tus pin 13
  6. VCC - +5 volts
  7. GND - Hauv av

Koj tseem yuav xav tau qee lub xov hlau los txuas cov zaub rau lub khob cij. Cov lus qhia feem ntau tuaj nrog qhov 7-tus pin header uas koj muab tso rau ntawm lub vijtsam. Kuv siv 7 tus txiv neej-rau-txiv neej 20mc Dupont cov khoom sib txuas thiab muag lawv kom cov xov hluav taws xob tuaj tawm tom qab ntawm cov zaub.

Kauj Ruam 3: Kauj Ruam 3: Txuas OLED mus rau Arduino Nano

Kauj Ruam 3: Txuas lub OLED rau Arduino Nano
Kauj Ruam 3: Txuas lub OLED rau Arduino Nano
Kauj Ruam 3: Txuas OLED mus rau Arduino Nano
Kauj Ruam 3: Txuas OLED mus rau Arduino Nano

Tam sim no koj tau npaj los sim koj li OLED. Kuv siv lwm Arduino Nano tsuas yog los sim tias txhua qhov khoom kuv tau ua haujlwm. Thaum qhov kev sim ua haujlwm ces kuv txuas nws mus rau tus neeg hlau. Daim duab kab hluav taws xob rau tus ntsuas hluav taws xob tau qhia hauv daim duab saum toj no. Nco ntsoov tias koj tuaj yeem txav cov OLED txuas mus rau lwm tus pin uas txhawb nqa cov txiaj ntsig digital, tab sis yog tias koj paub tseeb tias SCL (moos) nyob ntawm Arduino Nano tus pin 13 thiab SDA (cov ntaub ntawv) nyob ntawm Arduino Nano tus pin 11 koj tuaj yeem siv lub chaw teeb tsa hauv lub software. Qhov no khaws koj cov cai yooj yim me ntsis.

Kauj Ruam 4: Kauj Ruam 4: Kuaj Koj Cov Zaub

Kauj Ruam 4: Kuaj Koj Cov Zaub
Kauj Ruam 4: Kuaj Koj Cov Zaub

Txhawm rau ntsuas koj cov zaub peb yuav siv lub tsev qiv ntawv u8g2. Muaj lwm lub tsev qiv ntawv koj tuaj yeem siv tau, tab sis hauv kuv qhov kev paub, tsis muaj leej twg zoo li ntawm u8g2 lub tsev qiv ntawv. Ib qho tseem ceeb tshaj yog RAM npaum li cas hauv Arduino siv los ntawm cov zaub. U8g2 tsuas yog lub tsev qiv ntawv kuv pom uas siv "Hom Ntawv" uas yuav ua haujlwm nrog Arduino Nano.

Koj tuaj yeem ntxiv lub tsev qiv ntawv no rau koj Arduino IED los ntawm kev tshawb nrhiav "u8g2" hauv "Manage Libraries" menu. Koj tseem tuaj yeem rub tawm cov cai ncaj qha los ntawm gethub.

github.com/olikraus/u8g2

Qhov chaws xeem uas kuv siv yog nyob ntawm no:

github.com/dmccreary/coderdojo-robots/blob…

Muaj ob peb yam yuav tsum nco ntsoov. SCL thiab SDA tus lej tus lej tau hais tawm vim tias lawv yog tus lej pib ntawm Nano. Tus tsim rau u8g2 yog kab ntawv tseem ceeb:

// Peb tab tom siv SSD1306, 128x64, ib nplooj ntawv, tsis muaj npe, 4 xaim, Kho vajtse, SPI uas tsis muaj kev sib hloov uas tsuas yog siv 27% ntawm lub cim xeeb dynamicU8G2_SSD1306_128X64_NONAME_1_4W_HW_SPI u8g2 (U8G2_R0, CS_PIN, DC_PIN, RDS_P);

Peb tab tom siv hom ib nplooj ntawv txij li hom ntawd siv tsawg RAM. Peb tab tom siv 4-xaim kho vajtse interface thiab OLED los nrog SPI los ntawm lub neej ntawd.

Kauj Ruam 5: Kauj Ruam 5: Ntxiv Koj OLED rau Neeg Hlau

Kauj Ruam 5: Ntxiv Koj OLED rau Neeg Hlau
Kauj Ruam 5: Ntxiv Koj OLED rau Neeg Hlau

Tam sim no peb muaj OLED ua haujlwm thiab peb paub yuav pib li cas rau u8g2 cov tsev qiv ntawv peb tau npaj los koom ua ke OLED nrog peb lub hauv paus neeg hlau. Muaj ob peb yam los xav txog. Hauv peb qhov kev ntsuas OLED peb tau siv tus pin uas txhua tus nyob ib sab ua kom cov hlua yooj yim dua. Hmoov tsis zoo, peb xav tau tus pin 9 los tsav peb Tus Neeg Hlau vim nws yog ib qho ntawm PWM tus pin uas peb xav tau kom xa cov teeb liab sib piv rau tus tsav tsheb. Kev daws teeb meem yog txav cov hlau uas nyob ntawm tus pin 9 mus rau lwm tus pin dawb thiab tom qab ntawd hloov qhov #define nqe lus rau tus pin tshiab. Koj mus rau OLED ntawm sab xub ntiag ntawm tus neeg hlau kuv txiav ob daim duab peb sab tawm ntawm plexiglass thiab kub-glued lawv mus rau lub chassis. Kuv ib txwm nyiam siv qee cov ntawv xuab zeb kom ntxhib saum npoo ntawm plexiglass ua ntej kuv kub-nplaum cov ntu ua ke kom lawv tsis txhob sib nrug yooj yim.

Tom ntej no, cia peb tau txais qee cov ntaub ntawv ntawm peb OLED thiab kos qee lub ntsej muag ntawm tus neeg hlau!

Kauj Ruam 6: Kauj Ruam 6: Zaub Neeg Hlau Parameters

Kauj Ruam 6: Zaub Neeg Hlau Parameters
Kauj Ruam 6: Zaub Neeg Hlau Parameters

Ib qhov zoo uas hais txog kev muaj cov zaub yog qhov nws pab tau zoo hauv kev debug dab tsi tshwm sim hauv peb cov neeg hlau thaum nws tab tom tsav tsheb ncig. Nws tsis yog qhov tsis yooj yim rau cov tsim tawm kom muaj txoj haujlwm ua haujlwm ntawm lub desktop thaum koj txuas nrog koj lub khoos phis tawj nkaus xwb kom nws TSIS ua haujlwm thaum tus neeg hlau tsav tsheb ncig. Kev qhia tus nqi xws li qhov ntsuas ntsuas los ntawm ping sensor yog qhov piv txwv zoo ntawm kev ua kom pom tus neeg hlau ntsuas.

Hauv daim duab saum toj no, thawj kab (Echo Sijhawm) qhia lub sijhawm qeeb ntawm thaum lub suab tawm ntawm tus hais lus ultrasonic thiab lub sijhawm nws tau txais los ntawm lub microphone. Tus lej no tom qab hloov pauv mus rau centimeters hauv kab thib ob (nrug deb hauv cm). Lub txee tau hloov kho qhov kev tshawb nrhiav thib ob los qhia tias cov zaub tau hloov tshiab. Qhov "Tig …" tsuas yog tso tawm yog tias qhov kev ncua deb qis dua tus lej tshwj xeeb uas hu ua qhov pib tig. Ob lub log txav mus tom ntej yog qhov ping nrug deb dua tus lej no. Yog tias tus lej nyob hauv qab tig qhov pib ces peb thim rov qab lub cav (thaub qab) thiab tom qab ntawd hloov kev taw qhia.

Nov yog qee qhov qauv piv txwv uas qhia koj yuav ua li cas coj tus nqi los ntawm ping sensor thiab tso tawm qhov txiaj ntsig ntawm koj lub vijtsam OLED.

Nov yog qhov piv txwv uas ntsuas peb lub ping sensors (sab laug, nruab nrab thiab sab xis) thiab qhia qhov txiaj ntsig ntawm cov zaub:

github.com/dmccreary/coderdojo-robots/blob…

Kauj Ruam 7: Kauj Ruam 7: Kos Qee Lub ntsej muag

Kauj Ruam 7: Kos qee Lub ntsej muag!
Kauj Ruam 7: Kos qee Lub ntsej muag!

Tam sim no peb muaj txhua daim hauv qhov chaw los kos qee lub ntsej muag. Peb cov tub ntxhais kawm feem ntau xav tias tus neeg hlau yuav tsum muaj lub ntsej muag zoo siab yog nws tau tsav tsheb mus rau tom ntej. Thaum nws pom qee yam nyob rau hauv pem hauv ntej ntawm nws, nws sau npe qhov kev xav tsis thoob. Nws mam li thim rov qab thiab saib ib puag ncig, tej zaum nrog lub qhov muag txav mus rau lub cim qhia tias nws yuav tig mus li cas.

Cov lus txib kom kos lub ntsej muag yog yooj yim zoo nkauj. Peb tuaj yeem kos lub voj voog rau tus qauv ntawm lub ntsej muag thiab ua cov voj voog rau txhua lub qhov muag. Lub qhov ncauj tuaj yeem yog ib nrab lub voj voog rau luag nyav thiab puv lub voj voog rau qhov kev xav tsis thoob. Nov yog qhov chaw uas cov menyuam tuaj yeem siv lawv lub tswv yim los ua tus kheej cov lus. Qee zaum kuv txhob txwm kos lub ntsej muag tsis zoo thiab thov kom cov tub ntxhais kawm pab kuv ua kom lawv zoo dua.

Koj tuaj yeem siv lub display.height () thiab display.width () ua haujlwm kom tau txais qhov loj me ntawm cov zaub. Hauv cov cai hauv qab no peb teeb tsa qhov txawv

half_width = display.width ()/2; half_height = display.height ()/2;

Yog tias koj ua cov kev suav no ntau zaus, cov lej nrawm dua yog tias lawv suav ib zaug thiab khaws cia hauv qhov sib txawv. Nov yog qee qhov piv txwv ntawm yuav ua li cas tho qhov ncaj ncaj lub ntsej muag saum toj no:

// peb ua qhov no thaum pib ntawm txhua lub voj

display.clearDisplay (); // kos lub ntsej muag lub teeb rau tom qab pom kev.fillCircle (ib nrab_width, ib nrab_height, 31, WHITE); // txoj cai qhov muag tsaus nti display.fillCircle (ib nrab_width - 10, display.height ()/3, 4, BLACK); // sab laug qhov muag darkdisplay.fillCircle (half_width + 10, display.height ()/3, 4, BLACK); // kos kab ncaj rau lub qhov ncauj display.drawLine (half_width - 10, display.height ()/3 * 2, half_width + 10, display.height ()/3 * 2, BLACK); // kab ntawv no xa peb lub ntsej muag tshiab mus rau OLED zaub display.display ();

Kauj Ruam 8: Kauj Ruam 8: Kho kom haum

Kauj ruam 8: Kho kom haum
Kauj ruam 8: Kho kom haum

Teeb duab lub ntsej muag yooj yim yog qhov pib xwb. Cov tub ntxhais kawm tuaj yeem tsim ntau yam kev hloov pauv. Ntau tus tub ntxhais kawm tau ntxiv tus neeg hais lus me me uas ua suab nrov lossis suab nrov thaum lawv txav mus los.

Koj kuj tseem tuaj yeem tsim cov kev xeem me me uas pab koj cov tub ntxhais kawm txuas lub tshuab kom raug. Piv txwv li tus xub (daim duab peb sab) ntawm lub vijtsam yuav qhia tus tub ntxhais kawm paub tias lub log yuav tsum tig li cas thaum koj txuas lub cav. Qhov kev xeem ntsuas mus los ntawm txhua qhov kev qhia tsav:

  1. Txoj Cai Mus
  2. Txoj Cai Rov Qab
  3. Sab laug Mus Ntxiv
  4. Sab laug Rov Qab

Rau txhua hom, lub vijtsam raug hloov kho tshiab nrog cov zaub tshiab los qhia seb lub log twg yuav tsum tig thiab mus rau qhov twg.

Ib qho piv txwv ntawm txoj haujlwm ntawd nyob ntawm no

github.com/dmccreary/coderdojo-robots/blob…

Muaj ntau qhov piv txwv ntxiv thiab cov ncauj lus kom ntxaws ntawm CoderDojo Robots GitHub FaceBot nplooj ntawv.

Kuj tseem muaj qhov hloov pauv ntawm FaceBot tus neeg hlau uas tso cai rau cov tub ntxhais kawm hloov pauv txhua qhov kev sib tsoo kom tsis txhob muaj kev sib tsoo (rau pem hauv ntej nrawm, tig nrug, tig sijhawm, tig nrawm) ncaj qha siv cov zaub. Tsis muaj lub khoos phis tawj xav tau "program" cov neeg hlau no! Cov ntawv no zoo tagnrho rau MakerFairs thiab cov xwm txheej uas koj tsis xav nqa cov khoos phis tawj nyob ib puag ncig.

Thov qhia rau peb paub dab tsi tshiab ntsej muag koj thiab koj cov tub ntxhais kawm tuaj nrog!

Zoo siab coding!

Pom zoo: