Cov txheej txheem:

Ua pa LED Nrog Arduino Uno R3: 5 Cov Kauj Ruam
Ua pa LED Nrog Arduino Uno R3: 5 Cov Kauj Ruam

Video: Ua pa LED Nrog Arduino Uno R3: 5 Cov Kauj Ruam

Video: Ua pa LED Nrog Arduino Uno R3: 5 Cov Kauj Ruam
Video: NOOBS PLAY CLASH ROYALE FROM START LIVE 2024, Kaum ib hlis
Anonim
Ua pa LED Nrog Arduino Uno R3
Ua pa LED Nrog Arduino Uno R3

Hauv zaj lus qhia no, cia peb sim qee yam nthuav - hloov pauv qhov ci ntawm LED los ntawm kev ua haujlwm. Txij li lub teeb pom kev zoo li ua pa, peb muab nws lub npe hu ua pa - ua pa LED. Peb yuav ua tiav qhov txiaj ntsig no nrog mem tes dav tes taws los piav (PWM)

Kauj Ruam 1: Cheeb Tsam

- Arduino Uno board * 1

- USB cable * 1

- Tus tiv thaiv (220Ω) * 1

- LED * 1

- Daim phiaj * 1

- Jumper xov hlau

Kauj Ruam 2: Txoj Cai

Txoj Cai
Txoj Cai

Pulse dav tes taws los piav, lossis PWM, yog txheej txheem kom tau txais cov txiaj ntsig sib piv nrog cov txhais tau tias. Kev tswj hwm digital yog siv los tsim lub voos xwmfab, lub teeb liab hloov ntawm ntawm thiab tawm. Qhov kev hloov pauv no tuaj yeem sim ntsuas qhov nruab nrab ntawm tag nrho ntawm (5 Volts) thiab tawm (0 Volts) los ntawm kev hloov pauv ib feem ntawm lub sijhawm teeb liab siv rau ntawm lub sijhawm uas lub teeb liab siv tawm. Lub sijhawm "ntawm lub sijhawm" hu ua pulse width. Txhawm rau kom tau txais qhov sib txawv ntawm qhov sib piv, koj hloov pauv, lossis hloov pauv, qhov dav ntawd. Yog tias koj rov ua qhov txheej txheem no tawm sai txaus nrog qee lub cuab yeej, piv txwv li LED, nws yuav zoo li no: lub teeb liab yog qhov ruaj khov ntawm 0 thiab 5V tswj qhov ci ci ntawm LED. (Saib PWM kev piav qhia ntawm lub vev xaib raug cai ntawm Arduino).

Hauv cov duab hauv qab no, kab ntsuab sawv cev rau lub sijhawm tsis tu ncua. Lub sijhawm lossis lub sijhawm no yog qhov hloov pauv ntawm PWM zaus. Hauv lwm lo lus, nrog Arduino PWM zaus ntawm 500Hz, kab ntsuab yuav ntsuas 2 milliseconds txhua.

Kev hu xov tooj rau analogWrite () yog ntsuas ntawm 0 - 255, xws li analogWrite (255) thov kom muaj 100% kev ua haujlwm (ib txwm ua), thiab analogWrite (127) yog 50% kev ua haujlwm (ib nrab sijhawm) rau piv txwv

Koj yuav pom tias qhov me PWM tus nqi yog, tus nqi me me yuav yog tom qab hloov pauv mus rau qhov hluav taws xob. Tom qab ntawd LED ua dimmer raws li. Yog li ntawd, peb tuaj yeem tswj qhov ci ci ntawm LED los ntawm kev tswj hwm tus nqi PWM.

Kauj Ruam 3: Daim Duab Schematic

Schematic Daim duab
Schematic Daim duab

Kauj ruam 4: Cov txheej txheem

Cov txheej txheem
Cov txheej txheem
Cov txheej txheem
Cov txheej txheem

Los ntawm cov phiaj xwm, peb tuaj yeem siv analogWrite () ua haujlwm los sau qhov sib txawv rau tus pin 9. Lub teeb ci ntawm LED yuav hloov raws qhov ntawd. Ntawm SunFounder Uno board, tus pin 3, 5, 6, 9, 10, thiab 11 yog tus pin ntawm PWM (nrog "~" cim). Koj tuaj yeem txuas ib qho ntawm cov pins no.

Kauj ruam 1:

Tsim lub voj voog.

Kauj ruam 2:

Rub tawm cov cai los ntawm

Kauj ruam 3:

Tshaj tawm cov duab kos rau Arduino Uno board

Nyem rau Upload icon txhawm rau upload cov cai rau pawg tswj hwm.

Yog tias "Ua tiav uploading" tshwm nyob rau hauv qab ntawm lub qhov rais, nws txhais tau hais tias daim duab tau ua tiav tiav.

Ntawm no koj yuav tsum pom LED tau ci dua thiab ci dua, tom qab ntawd maj mam dimmer, thiab rov ci dua thiab dimmer ntau zaus, ib yam li ua pa.

Pom zoo: