Cia peb pom dab tsi yog tom qab PWM acronym, nws ua haujlwm li cas, nws yog rau dab tsi thiab peb yuav siv nws li cas hauv kev ua haujlwm nrog Arduino.
Tsim nyog
- - Arduino;
- - Hnav teeb ci;
- - tus tiv thaiv nrog qhov tsis kam ntawm 200 Ohm;
- - khoos phis tawj.
Cov Lus Qhia
Kauj ruam 1
Arduino digital pins tuaj yeem tsuas yog muab ob qho txiaj ntsig: logic 0 (LOW) thiab logic 1 (HIGH). Yog vim li cas lawv digital. Tab sis Arduino muaj cov lus "tshwj xeeb" xaus, uas yog tsim PWM. Qee zaum lawv qee tus cim nrog kab ntab "~" lossis ncig los yog qee qhov sib txawv ntawm lwm tus. PWM sawv rau "Pulse-dav tes taws los piav" lossis Pulse Dav Dav tes taws los piav, PWM.
Cov mem tes dav modulated teeb liab yog lub teeb liab mem tes ntawm lub zuj zus tas mus li, tab sis lub voj voog kuj tsis paub meej (qhov piv ntawm cov mem tes ntev rau nws lub sijhawm rov ua dua). Vim tias qhov txheej txheem feem ntau hauv lub cev muaj nyob rau hauv qee yam, inertia ntse, poob ntawm 1 mus rau 0 yuav smoothed tawm, noj qee tus nqi nruab nrab. Los ntawm teeb tsa lub sijhawm ua haujlwm, koj tuaj yeem hloov qhov nruab nrab qhov nruab nrab ntawm PWM rau cov zis.
Yog tias lub luag haujlwm lub voj voog yog 100%, tom qab ntawd txhua lub sijhawm ntawm cov zis digital ntawm Arduino yuav muaj qhov ntsuas voltage ntawm "1" lossis 5 volts. Yog tias koj tso lub voj voog lub luag haujlwm rau 50%, tom qab ntawd ib nrab ntawm lub sijhawm ntawm qhov tawm yuav yog cov thawj coj "1", thiab ib nrab - cov nqi "0", thiab qhov nruab nrab voltage yuav yog 2.5 volts. Nkaujhnubqub los ib yam.
Hauv qhov program, lub luag haujlwm ntawm lub luag haujlwm tau teeb tsa tsis yog ib feem pua, tab sis raws li tus lej los ntawm 0 txog 255. Piv txwv, cov lus txib "analogWrite (10, 64)" yuav qhia tus microcontroller kom xa cov teeb liab nrog lub luag haujlwm ntawm 25 % rau digital PWM tso zis # 10.
Arduino pins nrog cov mem tes dav dav tes taws los piav cov haujlwm ua haujlwm ntawm lub zaus ntawm 500 Hz. Qhov no txhais tau hais tias lub sijhawm ntsuas ntawm cov mem tes yog li 2 milliseconds, uas yog ntsuas los ntawm ntsuab ntsug cwj nrag hauv daim duab.
Nws hloov tawm tias peb tuaj yeem simulate cov teeb liab sib piv ntawm cov zis digital! Nthuav, txoj cai ?!
Peb yuav siv qhov no li cas? Muaj ntau ntau cov ntawv thov! Piv txwv, cov no yog LED qaim tswj, lub cev muaj zog ceev, transistor tam sim no tswj, suab tawm los ntawm lub piezo emitter …
Kauj ruam 2
Cia peb saib qhov piv txwv tseem ceeb tshaj plaws - tswj kev ci ntsa iab ntawm LED siv PWM. Peb muab tso ua ke ib txoj kab ke classic.
Kauj ruam 3
Cia peb qhib cov "Fade" kos duab los ntawm cov piv txwv: Cov Ntaub Ntawv -> Cov Qauv -> 01. Basics -> Fade.
Kauj ruam 4
Cia peb hloov nws me ntsis thiab thauj mus rau hauv Arduino lub cim xeeb.
Kauj ruam 5
Peb tig rau lub hwj chim. Cov LED zuj zus nyob rau hauv qhov ci ci thiab tom qab ntawd txo qis dua. Peb tau simulated cov teeb liab sib piv ntawm cov zis digital siv cov mem tes dav dav tes taws los piav.