Cov txheej txheem:

Project 2, Dimming LED: 3 Kauj Ruam
Project 2, Dimming LED: 3 Kauj Ruam

Video: Project 2, Dimming LED: 3 Kauj Ruam

Video: Project 2, Dimming LED: 3 Kauj Ruam
Video: Power LED Lights + Injection. Complete Walkthrough 2024, Kaum ib hlis
Anonim
Qhov project 2, Dimming LED
Qhov project 2, Dimming LED

Hauv txoj haujlwm no koj yuav kawm paub tswj hwm qhov ci ntawm LED nrog lub hwj chim li cas. Hauv txoj haujlwm no koj yuav raug qhia txog analogWrite, analogRead, thiab siv kev ua haujlwm int. Vam tias koj txaus siab rau nws, thiab nco ntsoov txheeb xyuas cov phiaj xwm yav dhau los uas muaj npe, Project 1, Blinking LED.

Kho vajtse yuav tsum tau:

  • Arduino UAS
  • Tsis Siv Neeg Breadboard
  • Teb Potentiometer
  • 6 jumper xov
  • LED
  • 220 ohm resistor

Software yuav tsum tau:

Arduino IDE Cov

Kauj ruam 1: Kho vajtse

Kho vajtse
Kho vajtse

Tsim lub Circuit ib yam li daim duab saum toj no.

Kauj ruam 2: Code

Tam sim no theej cov cai hauv qab no rau hauv Arduino IDE, yog tias koj tsis muaj nws muaj qhov txuas hauv qab ntawm nplooj ntawv.

int Sensorvalue = 0; // Qhia meej tias Sensorvalue sib npaug 0;

void teeb tsa () {

pinMode (8, NTAWV);

}

void voj () {

Sensorvalue = analogRead (A0); // Sensorvalue = tus pin A0, uas txuas nrog lub zog ntsuas

analogWrite (8, Sensorvalue/4); // siv analogWrite muaj nuj nqi peb tuaj yeem tswj tus pin 9 sai dua

}

Kauj ruam 3: Txheeb xyuas thiab Upload

Txheeb xyuas thiab xa koj cov cai rau koj li Arduino Code. Yog xav paub ntxiv txog qhov no txheeb xyuas kuv qhov haujlwm yav dhau los koj tuaj yeem pom qhov txuas hauv qab no. Thaum koj tus lej tau muab tso rau koj koj yuav tuaj yeem tswj qhov ci ntawm LED los ntawm kev tig lub hwj chim. Tam sim no tau muaj tswv yim. koj tuaj yeem sim tswj qhov nrawm ntawm lub tshuab dc siv ib qho.

Ntau txoj haujlwm yuav tawm los, nyob twj ywm thiab kawm paub yuav ua li cas thiaj nyeem tau deb, pom lub suab, ua si nco, tswb moos thiab ntau ntxiv.

Arduino IDE rub tawm:

www.arduino.cc/en/Main/Software

Kuv qhov project dhau los:

www.instructables.com/id/Project-1-Blinkin…

Pom zoo: