Cov txheej txheem:

Arduino Serial Monitor hauv Tinkercad: 7 Cov Kauj Ruam (nrog Duab)
Arduino Serial Monitor hauv Tinkercad: 7 Cov Kauj Ruam (nrog Duab)

Video: Arduino Serial Monitor hauv Tinkercad: 7 Cov Kauj Ruam (nrog Duab)

Video: Arduino Serial Monitor hauv Tinkercad: 7 Cov Kauj Ruam (nrog Duab)
Video: Wait what 😱 Flipper Zero 🐬 2024, Hlis ntuj nqeg
Anonim
Arduino Serial Monitor hauv Tinkercad
Arduino Serial Monitor hauv Tinkercad

Tinkercad Cov Haujlwm »

Ua kom taug qab txhua yam mus hauv koj qhov haujlwm tuaj yeem yog kev sib ntaus sib tua. Tus lej saib xyuas yog ib txoj hauv kev los mloog seb muaj dab tsi tshwm sim hauv koj cov cai los ntawm kev tshaj tawm rov qab mus rau lub khoos phis tawj hla USB cable. Hauv Tinkercad Circuits simulator, Serial Monitor tuaj yeem pom nyob hauv qab ntawm Code vaj huam sib luag thiab tseem tuaj yeem siv los teeb duab hloov pauv thaum lawv hloov pauv. Siv Serial Monitor los "tham" rau lub khoos phis tawj raws li txoj hauv kev los xyuas seb Arduino code ua raws li koj xav tau. Qhov no tuaj yeem muaj txiaj ntsig zoo rau kev daws teeb meem nrog koj cov cai (hu ua 'debugging serial').

Ob txoj kab hluav taws xob hauv zaj lus qhia no siv tib lub teeb tsa zoo ib yam li ob zaj lus qhia yav dhau los ntawm cov tswv yim digital nrog lub laub khawm thiab cov lus sib piv nrog lub hwj chim. Tsuas yog qhov sib txawv yog tias cov kab hluav taws xob no tau siv dawb-tsis muaj kab (tsis muaj daim ntawv qhia zaub mov) thiab tsis muaj LED sab nraud txuas. Auj, thiab lawv tab tom ua txoj cai los tsim cov ntawv xov xwm, uas peb yuav kawm txog hauv zaj lus qhia no.

Koj tuaj yeem ua raws nrog kev siv Tinkercad Circuits. Koj tseem tuaj yeem saib cov lus qhia no los ntawm hauv Tinkercad (yuav tsum tau nkag nkag dawb)! Tshawb xyuas cov qauv hluav taws xob thiab tsim koj tus kheej txoj cai ib sab ntawm nws. Tinkercad Circuits yog qhov browser pub dawb uas tso cai rau koj tsim thiab sim ua cov kab hluav taws xob. Nws zoo meej rau kev kawm, kev qhia, thiab kev tsim qauv.

Kauj Ruam 1: Luam tawm mus rau Serial Monitor With Blocks

Duab
Duab

Cia peb siv tus lej ntsuas tus lej txhawm rau mloog tus Arduino tus lej nkag, tom qab ntawv luam tawm tus nqi (analog) lossis lub xeev (digital) ntawm cov lus tawm hauv Serial Monitor window. Nyem rau "Code" khawm kom qhib lub vaj huam sib luag.

Nyem rau ntawm Serial Monitor hauv qab ntawm kab ntawv kab ntawv.

Nyem "Pib Simulation" txhawm rau ua piv txwv tus qauv Arduino, thiab saib cov lej hauv Serial Monitor thaum koj cuam tshuam nrog lub hwj chim. Koj tuaj yeem nyem rov qab thiab tawm ntawm ob Arduinos thaum qhov kev sim sim khiav hauv Tinkercad Circuits, tab sis tsuas yog cov Circuit sib piv yuav tso tawm hauv cov qauv teeb tsa saum toj no.

Tom qab theej cov qauv hauv Circuit mus rau hauv koj tus lej Tinkercad, koj tuaj yeem hloov txoj cai. Nkag mus rau qeb Cov Cai Tso Tawm, tom qab ntawd rub tawm qhov "luam tawm mus rau lub luag haujlwm saib xyuas" thaiv thiab tso nws ua ntej ntu ntu uas twb muaj lawm hauv qhov haujlwm.

Hloov cov ntawv sau ua cim los cim koj cov ntaub ntawv Serial, xws li "sensor:" (tsis txhob hnov qab qhov chaw tom qab txoj hnyuv), thiab kho cov ntawv qhia zaub mov nco tseg kom luam tawm yam tsis muaj kab tshiab.

Pib qhov kev sim thiab saib qhov kev hloov pauv hauv Serial Monitor. Koj tuaj yeem teeb tsa cov ntu ntu zoo li qhov no los tsim cov lus tawm tswv yim tseem ceeb thaum tsim ib txoj haujlwm twg.

Kauj ruam 2: Serial Monitor Arduino Code Piav Qhia

Duab
Duab

Thaum tus lej hloov pauv tau qhib hauv Tinkercad Circuits, koj tuaj yeem nyem cov ntawv qhia zaub mov nyob rau sab laug thiab xaiv "Blocks + Text" kom nthuav qhia Arduino code tsim los ntawm cov lej thaiv (tsis muaj nyob hauv cov qauv teeb tsa hauv thawj kauj ruam). Txoj cai no xa cov ntaub ntawv los ntawm Arduino mus rau Serial Monitor, tab sis hauv tshooj lus tom qab koj tseem tuaj yeem kawm paub yuav txais cov ntaub ntawv li cas los ntawm Serial monitor thiab ob txoj hauv kev sib txuas lus.

/*

DigitalReadSerial Nyeem cov ntaub ntawv digital ntawm tus pin 2, luam tawm qhov tshwm sim mus rau tus lej saib xyuas Tus lej piv txwv no nyob hauv zej tsoom. */

Ua ntej lub

teeb ()

peb tuaj yeem pom cov kab lus sib tham uas pib nrog

/*

thiab xaus nrog

*/

int buttonState = 0;

Thaum pib ntawm peb qhov haujlwm, peb yuav tsim qhov sib txawv los tuav lub xeev ntawm kev tawm tswv yim.

void teeb tsa ()

{pinMode (2, INPUT); Serial.begin (9600); }

Sab hauv teeb tsa, ib yam li hauv kev qhia analog thiab digital, tus pin txuas nrog rau qhov hloov lossis lub teeb tsa tau teeb tsa los ua cov tswv yim siv

pinMode ()

muaj nuj nqi Yuav kom tuaj yeem xa xov, Arduino xav tau qhib kev sib txuas lus tshiab nrog

Serial.begin ()

. Nws zoo li nias lub pob hu ntawm lub xov tooj-txij lub sijhawm ntawd koj qhib kab kev sib txuas lus rau kev hu xov tooj. Kev sib cav qhia rau Arduino sai npaum li cas los sib txuas lus, piv txwv li 9600 ntsis ib ob (aka baud).

void lub voj ()

{// nyeem tus lej nkag khawm buttonState = digitalRead (2); // luam tawm lub xeev ntawm khawm Serial.print ("sensor:"); Serial.println (buttonState); ncua (10); // Ncua me ntsis txhawm rau txhim kho kev sim sim ua tau zoo}

Cov cai sab hauv lub voj nyeem lub xeev ntawm kev tawm tswv yim nrog digitalRead () thiab khaws nws hauv pob khawm Hloov pauv. Tom qab ntawd muaj nuj nqi hu ua

Serial.println ()

xa cov ntaub ntawv mus rau tus saib xyuas (hla USB cable hauv rooj plaub ntawm Arduino lub cev). Yog tias koj tau ua cov kev hloov pauv rau txoj haujlwm hauv cov kauj ruam dhau los, koj tseem yuav muaj

Serial.print ()

kab ntawm txoj cai.

println

xa kab tshiab tom qab cov lus, thiab

luam tawm

tsis. Siv cov lus hais ib ncig ntawm cov ntawv lo, piv txwv

Serial.print ("sensor:");

. Yog tias koj xav ua ib kab ntawm cov lej debugging tso tawm, koj tuaj yeem siv ntau yam

Serial.print ()

commands ua raws li ib zaug

Serial.println ()

Kauj ruam 3: Txoj Cai Debugger

Duab
Duab

Muaj qhov tshwj xeeb hauv Tinkercad Circuits hu ua Debugger. Nws nqis los ntawm koj cov cai thiab tso cai rau koj saib xyuas koj cov kev hloov pauv thiab ntau ntxiv.

Nrog tus kws kho qhov chaws qhib, nrhiav Debugger los ntawm kev nyem lub pob nrog lub cim kab.

Hauv Thaiv + Hom ntawv (lossis hom ntawv nkaus xwb, yog tias koj xav tau), nyem kab kab ntawv txhawm rau txhawm rau txhawm rau txhawm rau, qhov twg debugger yuav nres txhua lub sijhawm los ntawm lub voj.

Pib simulation.

Hover hla qhov hloov pauv thaum ncua kom pom lawv qhov txiaj ntsig.

Kauj Ruam 4: Pib Pib Pib Circuit Court

Basic Serial Circuit Pib
Basic Serial Circuit Pib

Cov kab hluav taws xob no muaj nyob raws li pib siv hluav taws xob. Koj tuaj yeem siv cov pib hluav taws xob no txhua lub sijhawm koj xav nyeem cov ntawv digital lossis analog thiab luam nws lub xeev rau Serial Monitor.

Laub Arduino pib pib los ntawm cov khoom vaj huam sib luag (cov ntawv qhia zaub mov nco -> Pib -> Arduino).

Kauj Ruam 5: Teeb Duab Cov Ntaub Ntawv

Cov Ntaub Ntawv Teev Npe
Cov Ntaub Ntawv Teev Npe

Tinkercad Circuits kuj tseem muaj cov duab teeb tsa ntawm koj cov ntaub ntawv xov xwm, muab cov kwj dej tsis muaj cov ntawv hauv nws. Qhov no yooj yim rau pom qhov kev hloov pauv ntawm kev nyeem sensor thiab lwm cov tswv yim, nrog rau txhawm rau taug qab cov kev hloov pauv hauv koj qhov haujlwm.

Nrog rau Serial saib qhib, nyem lub pob teeb kom qhib lub teeb duab. Tshem tawm lub cim cim cim thaiv uas koj tau ntxiv ua ntej, lossis siv lub tshiab Arduino cov ntawv pib ua haujlwm los tsim cov ntaub ntawv xov xwm txuas nrog tsis muaj ntawv nyeem.

Pib qhov kev sim thiab cuam tshuam nrog cov tswv yim los saib cov duab teeb pom kev hloov.

Kauj Ruam 6: Sim Nws Nrog Lub Cev Arduino Circuit (Yeem Tau)

Duab
Duab

Koj muaj qhov kev xaiv los tsim lub cev hluav taws xob kom mus nrog qhov no lossis cov tswv yim digital lossis cov lus qhia sib piv, tom qab ntawd siv koj lub khoos phis tawj Arduino software los saib cov ntaub ntawv xov xwm nkag los ntawm USB cable. Txhawm rau teeb tsa koj lub cev Arduino Uno, koj yuav tsum teeb tsa software dawb (lossis txuas rau lub vev xaib khoos phis tawj), tom qab ntawd qhib nws.

Hlau txuas rau Arduino Uno Circuit los ntawm kev ntsaws rau hauv cov khoom sib txuas thiab cov xov hlau kom phim cov kev sib txuas uas pom ntawm no hauv Tinkercad Circuits. Yog xav paub ntau ntxiv-taug kev-ua haujlwm nrog koj lub cev Arduino Uno pawg thawj coj, txheeb xyuas cov lus qhia dawb Arduino chav kawm (cov lus sib tham tau piav qhia hauv tshooj peb).

Luam cov cai los ntawm Tinkercad Circuits code lub qhov rai thiab muab nws tso rau hauv qhov kos duab khoob hauv koj li Arduino software, lossis nyem lub pob rub tawm (nqes mus rau xub xub xub) thiab qhib

qhov ua tiav cov ntaub ntawv siv ArduinoKoj tseem tuaj yeem pom cov piv txwv no hauv Arduino software los ntawm kev mus rau File -> Piv txwv -> 03. Analog -> AnalogInOutSerial lossis File -> Piv txwv -> 02. Digital -> DigitalInputPullup.

Txuas koj lub USB cable thiab xaiv koj lub rooj tsavxwm thiab chaw nres nkoj hauv software cov cuab yeej ntawv qhia zaub mov.

Tshaj tawm cov cai rau koj lub rooj tsavxwm, tom qab ntawd nyem lub iav tsom iav lub cim nyob rau sab xis saum toj kom qhib lub ntsuas saib. Txheeb xyuas ob zaug tias tus nqi baud zoo ib yam hauv koj qhov teeb tsa

Serial.begin (9600)

Nias lub pob nyem lossis tig lub pob qhov rooj thiab saib cov lej hloov pauv hauv koj lub Serial Monitor window.

Kauj Ruam 7: Tom ntej no, Sim…

Tom ntej no, Sim…
Tom ntej no, Sim…

Tam sim no koj tau kawm luam tawm rau Serial Monitor, koj tau npaj los sim tawm yam tshiab ntawm digital thiab analog sensors, thiab tseem kawm nyeem cov ntaub ntawv xov xwm nkag (tus neeg siv cov keyboard nkag).

Koj puas tuaj yeem sau ib kab lus thiab ib qho program uas luam tawm ob qho tib si analog thiab digital uas tau qhia hauv zaj lus qhia no?

Nov yog qhov txuas rau daim duab duab, thiab nws Arduino code:

int int buttonState = 0;

int sensorValue = 0; teeb tsa tsis muaj dab tsi () {pinMode (2, INPUT); pinMode (A0, INPUT); Serial.begin (9600); } tsis muaj dab tsi voj () {// nyeem cov lej nkag khawm buttonState = digitalRead (2); // nyeem cov tswv yim ntawm tus pin analog 0: sensorValue = analogRead (A0); // luam qhov tseem ceeb rau tus saib xyuas Serial.print (buttonState); Serial.print (","); Serial.println (sensorValue); ncua (10); // Ncua me ntsis txhawm rau txhim kho kev sim sim ua tau zoo}

Txuas ntxiv mus sim lub ntsuas tshiab thiab sib txuas cov tswv yim thiab cov txiaj ntsig, piv txwv li hauv qhov ntsuas kub ntsuas LED kab teeb duab qhia, PIR tsab ntawv tsa suab sensor zaj lus qhia, lossis zaj lus qhia photoresistor. (yuav los sai sai). Saib koj lub khoos phis tawj keyboard kom xa cov ntaub ntawv txuas mus rau koj Arduino thiab txhais nrog

Serial.read ()

(zaj lus qhia yuav los sai sai no).

Koj tseem tuaj yeem kawm paub ntau yam txuj ci hluav taws xob nrog chav qhia dawb hauv Arduino, Cov Khoom Siv Hluav Taws Xob, LEDs & Teeb pom kev zoo, Luam Ntawv 3D, thiab ntau ntxiv.

Pom zoo: