Cov txheej txheem:
- Kauj Ruam 1: Pulse Width Modulation
- Kauj ruam 2: LED thiab Resistor
- Kauj ruam 3: Un-even Dimming
- Kauj Ruam 4: Kauj Ruam 4: nce thiab nqis hauv Ib Rau Rau (), thiab ntawm Tus Nqi Txawm
Video: RaspberryPi: Teem ib qho LED hauv thiab Tawm: 4 Kauj Ruam (nrog Duab)
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Cov theem hauv qab no yog kev sim ua piv txwv seb LEDs ua haujlwm li cas. Lawv qhia yuav ua li cas dim ib qho LED ntawm tus nqi sib npaug thiab yuav ua li cas thiaj ploj nws hauv thiab tawm.
Koj yuav xav tau:
- RaspberryPi (Kuv siv Pi qub, kuv Pi-3 tau siv, tab sis Pi yuav ua haujlwm.)
- Cov qhob cij
- 5 hli liab LED
- 330 Ω Resistor (Tsis tseem ceeb 220-560 Ω yuav ua haujlwm.)
- Hookup Hlau
Pi-cobbler Kuv siv los ntawm Adafruit tsis tsim nyog, tab sis nws ua rau daim ntawv qhia zaub mov yooj yim dua.
WiringPi yog teeb tsa cov tsev qiv ntawv rau phiaj xwm RaspberryPi hauv C. Cov lus qhia rau rub tawm, teeb tsa thiab siv yog nyob ntawm
Txhawm rau teeb tsa wiringPi ua raws cov lus qhia ntawm nplooj ntawv no:
Txhawm rau kom tau txais cov npe wiringPi tus lej tus lej nkag mus gpio nyeem ntawv ntawm kab hais kom ua.
Hauv cov ntawv tshiab ntawm Raspian wiringPi tau teeb tsa los ntawm lub neej ntawd.
Kauj Ruam 1: Pulse Width Modulation
LEDs ib txwm khiav ntawm tib qhov hluav taws xob tsis hais txog qhov ci ntsa iab. Qhov ci ntsa iab tau txiav txim siab los ntawm ib puag ncig yoj oscillator thiab lub sijhawm uas qhov hluav taws xob siab txiav txim siab qhov ci ci. Qhov no hu ua Pulse Width Modulation (PWM). Qhov no yog tswj los ntawm wiringPi pwmWrite (tus pin, n) ua haujlwm qhov twg n muaj tus nqi los ntawm 0 txog 255. Yog tias n = 2 LED yuav ci dua li n = 1. Qhov ci ci ib txwm ob npaug thaum n ob npaug. Yog li n = 255 yuav yog ob zaug ci li n = 128.
Tus nqi ntawm n feem ntau qhia raws li feem pua hu ua lub voj voog ua haujlwm. Cov duab qhia pom oscilloscope taug qab rau 25, 50 thiab 75% kev ua haujlwm.
Kauj ruam 2: LED thiab Resistor
Qhov no tsis yog qhov xav tau, tab sis muaj ob peb yam ntawm cov no tuaj yeem ua rau ua mov ci yooj yim dua.
Solder tus tiv thaiv kom luv luv ntawm LED. Siv 220-560 Ohm resistor.
Kauj ruam 3: Un-even Dimming
Tsim lub Circuit Court zoo li hauv daim duab. Qhov no zoo ib yam li lub voj voog kom ntsais ib qho LED. Nws siv wiringPi tus pin 1 vim tias koj xav tau siv PWM qhib tus pin. Sau cov program thiab khiav nws. Koj yuav pom tias qhov ci ntsa iab ntawm LED yog qhov qeeb nws dims. Raws li nws tau ze rau qhov dimmest nws yuav tau dimmer sai heev.
/******************************************************************
* Sau ua ke: gcc -o fade1 -Wall -I/usr/local/suav nrog -L/usr/local/lib * fade1.c -lwiringPi * * Ua: sudo./fade1 * * Txhua tus lej tus lej yog xaimPi tus lej tshwj tsis yog lwm yam tshwj xeeb. ********************************************************** ****** ****************/ #include int main () {wiringPiSetup (); // Teeb tsa xav tau los ntawm wiringPi pinMode (1, PWM_OUTPUT); // pwmSetMode (PWM_MODE_MS); // Mark/Space mode int kuv; thaum (1) {rau (i = 255; i> -1; i--) {pwmWrite (1, i); ncua (10); } rau (i = 0; i <256; i ++) {pwmWrite (1, i); ncua (10); }}}
Cov kauj ruam tom ntej qhia yuav ua li cas dim lub LED ntawm tus nqi tas li, thiab hauv ib qho rau nqe lus.
Kauj Ruam 4: Kauj Ruam 4: nce thiab nqis hauv Ib Rau Rau (), thiab ntawm Tus Nqi Txawm
Rau LED kom dim ntawm qhov tsis tu ncua ncua () yuav tsum nce ntawm qhov nthuav tawm vim tias ib nrab ntawm lub luag haujlwm yuav ib txwm ua ib nrab qhov ci ntsa iab.
Kab:
int d = (16-i/16)^2;
laij cov xwm txheej hloov pauv ntawm qhov ci ci los txiav txim qhov ncua ntawm qhov ncua. Sib sau ua ke thiab ua haujlwm qhov no thiab koj yuav pom tias LED yuav ploj mus thiab tawm ntawm qhov tsis tu ncua.
/******************************************************************
* Sau: gcc -o fade1 -Wall -I/usr/local/suav nrog -L/usr/local/lib * fade2.c -lwiringPi * * Ua: sudo./fade2 * * Txhua tus lej tus lej yog xaimPi tus lej tshwj tsis yog lwm yam tshwj xeeb. ********************************************************** ****** ****************/ #include int main () {wiringPiSetup (); // Teeb tsa xav tau los ntawm wiringPi pinMode (1, PWM_OUTPUT); // pwmSetMode (PWM_MODE_MS); // Kos/Hom chaw thaum (1) {int i; int x = 1; rau (i = 0; i> -1; i = i + x) {int d = (16 -i/16)^2; // calc inverse square ntawm qhov ntsuas pwmWrite (1, i); ncua (d); yog (i == 255) x = -1; // hloov kev taw qhia ntawm qhov siab}}}
Pom zoo:
Yuav Ua Li Cas Thiaj Li Tawm Tawm Tawm Tawm Rau Hauv Kev Hloov Pauv Hloov?: 6 Cov Kauj Ruam
Yuav Ua Li Cas Thiaj Li Ua Tus Tawm Tawm Tawm Rau Hauv Kev Hloov Transformer?: Yog tias koj xav tau tus tswv lub zog hloov pauv, tom qab ntawd koj yuav tsum tau nyeem kab lus no. Peb yuav xav ua kom tus neeg hloov pauv ntawm txhais ceg txav mus, ua haujlwm yooj yim thiab hais ob peb yam, lossis tseem paub yuav ua li cas sawv, zaum thiab yoj tes. Lub zog los ntawm
Kho Ob Chav Tawm Tawm Tawm Tawm Tawm Cov Khoom Siv Hluav Taws Xob: 10 Cov Kauj Ruam (nrog Duab)
Kho Ob Chav Tawm Tawm Tawm Tawm Tawm Tawm Cov Khoom Siv Hluav Taws Xob: Nta: AC-DC Hloov pauv ob npaug tso tawm qhov hluav taws xob (Zoo-Hauv av-Tsis Zoo) Kho txoj kab zoo thiab tsis zoo Tsuas yog Ib Leeg Ib Leeg AC hloov pauv cov suab nrov (20MHz-BWL, tsis muaj thauj khoom): Ib puag ncig 1.12mVpp Tsawg suab nrov thiab cov txiaj ntsig ruaj khov (zoo tagnrho
Lub Sijhawm Teem Sijhawm Teem Sijhawm ntawm RaspberryPi-4: 6 Cov Kauj Ruam (nrog Duab)
Lub Sijhawm Teem Sijhawm Teem Sijhawm ntawm RaspberryPi-4: Hauv Cov Lus Qhia no peb yuav ua lub ntsej muag-paub lub sijhawm tiag tiag ntawm Raspberry Pi 4 nrog Shunya O/S siv Shunyaface Library. Koj tuaj yeem ua tiav qhov ntsuas pom ntawm 15-17 ntawm RaspberryPi-4 los ntawm kev ua raws cov lus qhia no
Teem ib qho LED hauv thiab Tawm: 3 Kauj Ruam
Fade ib qho LED hauv thiab Tawm: Cov theem hauv qab no yog kev sim los qhia txog tias LEDs ua haujlwm li cas. Lawv piav qhia yuav ua li cas dim ib qho LED ntawm tus nqi sib npaug thiab yuav ua li cas kom nws ploj mus thiab tawm. Koj yuav xav tau: Arduino (Kuv siv duo) Breadboard 5 mm liab LED 330 Ω Tiv thaiv
Yuav Ua Li Cas Txuas Tus Fader Nrog Kev Tawm Suab thiab Tawm Tawm: 14 Cov Kauj Ruam
Yuav Ua Li Cas Txuas Tus Fader Nrog Suab Tawm Tswv Yim thiab Tawm Tawm: Tus fader yog ib qho ntawm cov hauv paus ntsiab lus rau kev sib xyaw ua ke. Koj tuaj yeem tswj hwm koj lub hauv paus nrog kev txav ntawm fader. Muaj ntau txoj hauv kev los siv cov khawm thawb hauv koj cov phiaj xwm (piv txwv li nyiag nkas nas thiab keyboard, lossis Arduino, tau txais, MC