Cov txheej txheem:

Arduino Tsev Siv Hluav Taws Xob: 5 Kauj Ruam
Arduino Tsev Siv Hluav Taws Xob: 5 Kauj Ruam

Video: Arduino Tsev Siv Hluav Taws Xob: 5 Kauj Ruam

Video: Arduino Tsev Siv Hluav Taws Xob: 5 Kauj Ruam
Video: Qhia txuas xaim hluav taws xob daim: 02 2024, Kaum ib hlis
Anonim
Arduino Tsev Siv Hluav Taws Xob
Arduino Tsev Siv Hluav Taws Xob

Koj tab tom tsim Lub Tsev Hluav Taws Xob Hauv Tsev uas yog los saib xyuas koj lub tsev lub zog txhawm rau txiav nyiaj hluav taws xob thiab lwm yam nqi hluav taws xob. Hauv tus qauv no, koj lub cuab yeej tuaj yeem tshuaj xyuas qhov kub ntawm koj lub tsev thiab kho nws kom raug, txheeb xyuas seb puas muaj lub qhov rooj lossis lub qhov rais qhib sab laug txhawm rau txuag hluav taws xob thiab cua txias, thiab tso cai rau tus neeg siv phau ntawv tswj qhov ci ntawm lub teeb hauv koj lub tsev. Cia peb pib!

Kauj Ruam 1: Cov Khoom thiab Cov Khoom

Koj yuav xav tau ntau yam los ua kom tiav cov kab ke no. Ua ntej tshaj plaws, koj yuav xav tau Sparkfun Redboard cov khoom siv pib, siv los ntawm Arduino. Cov khoom siv no thiab kho vajtse sab hauv yuav yog qhov uas koj teeb tsa tag nrho cov kab ke. Qhov thib ob, koj yuav xav tau daim ntawv theej ntawm MATLAB ntawm koj lub khoos phis tawj lossis lub khoos phis tawj, nrog rau txhua yam ntawm cov cuab yeej tsim nyog txhawm rau txhawm rau ua kom sib xws nrog Redboard. Txhawm rau ua li ntawd, qhib MATLAB. Ntawm MATLAB Tsev tab, hauv Cov Ntawv Qhia Ib puag ncig, xaiv Ntxiv-Tau Txais Cov Khoom Pab Txhawb Cov Khoom Xaiv "MATLAB Txhawb Pob rau Arduino Kho Vajtse" thiab rub tawm Arduino Cov Khoom Pab Txhawb.

Cov seem uas koj xav tau yog suav nrog hauv Sparkfun Redboard pob. Koj yuav xav tau cov xov hlau, ib qho LED, tus tiv thaiv, diode, lub hauv paus piezo (hais lus), ntsuas kub, transistor, photoresistor, thiab DC Motor. Hmoov zoo, tag nrho cov khoom no tau pom hauv koj lub pob pib.

Kauj Ruam 2: Teeb Koj Lub Teeb Tswj

Teeb Koj Lub Teeb Tswj
Teeb Koj Lub Teeb Tswj

Hauv kab ke no, lub teeb LED yuav yog peb lub teeb hauv tsev. Txuas nrog yog daim duab ntawm lub Circuit Court xav tau rau koj los teeb tsa LED tswj ntawm koj li Redboard. Hauv qhov xwm txheej no, koj yuav tsis xav tau daim xiav ntawm lub voj voog.

Cov cai hauv qab no yuav teeb tsa koj kev tswj hwm lub teeb ci LED. Thaum khiav cov cai, cov ntawv qhia zaub mov yuav tshwm sim, tso cai rau tus neeg siv xaiv qhov ci ci ntawm qhov siab, nruab nrab, qis, lossis tawm. Nyob ntawm seb koj xaiv dab tsi, txoj cai yuav teeb tsa LED los ua qee yam ntawm qhov ci lossis qhov ci. Qhov no yuav yog lub voj tsis paub kawg.

%% teeb

xaiv = ntawv qhia zaub mov ('Koj xav tau koj lub teeb zoo li cas?', 'Siab', 'Nruab Nrab', 'Tsawg', 'Tawm')

yog xaiv == 1

writePWMVoltage (a, 'D10', 5)

elseif xaiv == 2

writePWMVoltage (a, 'D10', 3)

lwm txoj kev xaiv == 3

writePWMVoltage (a, 'D10', 1)

lwm txoj kev xaiv == 4

writePWMVoltage (a, 'D10', 0)

kawg

Kauj Ruam 3: Teeb Lub Qhov Rooj thiab Lub Tswb Tswb

Teeb Qhov Rooj thiab Qhov Rooj Tswb
Teeb Qhov Rooj thiab Qhov Rooj Tswb
Teeb Qhov Rooj thiab Qhov Rooj Tswb
Teeb Qhov Rooj thiab Qhov Rooj Tswb

Thawj qhov txuas txuas yuav qhia koj yuav teeb tsa tus hais lus me me ntawm koj li Redboard li cas. Tus neeg hais lus no yuav ua tus ceeb toom qhia rau tus neeg siv paub tias lub qhov rooj lossis lub qhov rooj hauv lawv lub tsev tau qhib lawm ntau dua 10 vib nas this. Lub voj voog no siv cov xov hlau, lub hauv paus piezo, thiab 3 xov hlau.

Qhov txuas thib ob yog ntawm tus kws yees duab. Qhov no tuaj yeem qhia tau yog tias thaj tsam ib puag ncig tsaus ntuj lossis tsaus. Lub teeb pom kev yuav qhia rau MATLAB cov cai paub yog lub qhov rooj qhib lossis kaw, thiab yuav xa cov ntaub ntawv mus rau lub ntsiab lus piezo, qhia nws ua suab nrov. Hauv kab lus no, koj yuav tsis tas yuav txuas lub LED, xaim xaim, lossis tiv thaiv sab xis.

Cov cai hauv qab no yuav nyeem tus nqi ntawm lub teeb los ntawm tus kws yees duab, tom qab ntawd ncua txoj cai kom pom tias lub qhov rooj qhib qhib rau ntau dua 10 vib nas this. Nws yuav nyeem lub photoresistor dua, tom qab ntawd qhia lub piezo kom nrov nrov yog tias lub teeb theem tseem siab dhau.

%% Photoresistor

thaum 0 == 0

photov = nyeemVoltage (a, 'A1')

yog tias photov> 4

ncua (10)

photov = nyeemVoltage (a, 'A1')

yog tias photov> 4

playTone (a, 'D3', 500, 5)

so

kawg

kawg

kawg

Kauj Ruam 4: Teeb Tshav Kub Kub

Teem Sij Hawm Kub Kub
Teem Sij Hawm Kub Kub
Teem Sij Hawm Kub Kub
Teem Sij Hawm Kub Kub

Thawj qhov txuas txuas yuav teeb tsa koj qhov ntsuas kub. Qhov no yuav sau cov ntaub ntawv ntsuas kub los ntawm txhua qhov chaw uas koj tau tso rau hauv. Nws yuav xa cov ntaub ntawv no mus rau MATLAB.

Cov kab hluav taws xob txuas tom ntej teeb tsa DC lub cav. Lub cav no ua haujlwm raws li tus kiv cua. Yog tias qhov ntsuas kub tau nyeem siab dhau, kiv cua yuav qhib, thiab sim ua kom koj lub tsev txias.

Cov cai hauv qab no yuav tso cai ntsuas qhov ntsuas kub kom nyeem cov ntaub ntawv dhau sijhawm teem sijhawm. Cov cai no tau teeb tsa los ntawm 100 zaug, tab sis tuaj yeem hloov kho kom yooj yim dua rau ntau lub sijhawm, yog li lub ntsuas hluav taws xob tuaj yeem ua haujlwm nyob rau ib hnub. Raws li nws sau cov ntaub ntawv ntsuas kub, cov cai kuaj xyuas seb qhov kub puas tau nce siab dua qhov ntsuas kub. Yog tias ua tau, tus kiv cua yuav cia li qhib. Thaum lub sijhawm teem sijhawm tas, nws yuav tsim cov phiaj xwm uas qhia koj qhov kub thiab txias thoob plaws lub sijhawm uas koj tuaj yeem tshuaj xyuas txhawm rau txhawm rau kho cua sov thiab cua txias hauv koj lub tsev.

%% Kub Sensor

sijhawm =

zaug =

rau kuv = 1: 100

v = nyeemVoltage (a, 'A0')

tempC = (v-0.5).*100

tempF = 9/5.* tempC + 32

Yog tias tempF> 75

writeDigitalPin (a, 'D9', 1)

kawg

temps = [sijhawm, tempF]

sij hawm = [zaug, kuv]

lub sijhawm (sijhawm, sijhawm)

xlabel ('Sijhawm (vib nas this)')

ylabel ('Kub (F)')

lub npe ('Kub ntawm Koj Lub Tsev Nyob Sijhawm')

kawg

Kauj Ruam 5: Xaus

Koj nyob nraum tag nrho! Txaus siab rau koj lub zog txuag tsev tshiab, thiab nco ntsoov siv nws kom tau txais txiaj ntsig!

Pom zoo: