Cov txheej txheem:

Ob Chav Pushbutton LED Circuit: 5 Kauj Ruam
Ob Chav Pushbutton LED Circuit: 5 Kauj Ruam

Video: Ob Chav Pushbutton LED Circuit: 5 Kauj Ruam

Video: Ob Chav Pushbutton LED Circuit: 5 Kauj Ruam
Video: How To Clean Ear Wax Properly #shorts 2024, Kaum ib hlis
Anonim
Ob Chav Pushbutton LED Circuit
Ob Chav Pushbutton LED Circuit

Kuv yuav sim kuv lub suab kom zoo li qub txhais tes ntawm kev ua haujlwm thiab ua haujlwm nrog arduinos tab sis, qhov tseeb raug hais, qhov tseeb kuv tsuas yog qhia rau cov no ob peb hnub dhau los, yog li kuv muaj kev xyiv fab dhau los ntawm kev ua tiav thiab tsim kuv lub program tus kheej li project sai sai no.

Qhov haujlwm no tau pib tawm los ntawm kev twv los ntawm tus kws tshaj lij phooj ywg ntawm kuv niam kuv txiv tias kuv yog tus kws kho mob rau ob peb hnub. Kuv nyiam cov nyom, muaj qee yam hauv kev sib tw uas ua rau kuv zoo siab thiab ua rau kuv thiab muaj kev txaus siab txaus siab thaum kuv ua tiav, thiab kuv vam tias koj yuav ua ib yam.

Hauv cov lus qhia no, kuv thawj zaug puas tau: D, Kuv yuav qhia koj yuav ua li cas txuas lub Circuit Court rau qhov kuv hu ua Kuv Mark Ib qhov haujlwm, ib qho Circuit Court uas ob lub laub-khawm tswj lub teeb ci ntawm LED (ib qho yuav ua rau kom pom qhov ci thiab qhov thib ob) yuav txo nws) nrog rau yuav ua li cas rau nws thiab phiaj xwm koj cov txiaj ntsig ntawm cov cuab yeej ntsuas xyuas. Kuv yuav qhia koj raws nraim qhov koj xav tau nrog rau cov lus qhia ib qib zuj zus hais txog yuav tsim nws li cas. Kuv txoj haujlwm suav nrog cov ntsiab lus ntawm ob lub laub-khawm- ntxiv rau cov lus qhia ploj ntawm lub vev xaib qhia thiab tau tawm tswv yim hnyav rau kuv tus kheej yooj yim ib yam li koj li. Yog tias koj tseem tsis tau paub txog cov lus programming thov siv sijhawm, nws tsim nyog nws.

Txaus siab rau!

Kauj Ruam 1: Cov Ntaub Ntawv + Cov Cuab Yeej:

Cov Ntaub Ntawv + Cov Cuab Yeej
Cov Ntaub Ntawv + Cov Cuab Yeej

Cov ntaub ntawv:

1. Ib pawg Arduino (Kuv siv Mega 2560)

2. Lub khob cij (nrog tsawg kawg 60 kab)

3. Ib qho LED (xim twg, Kuv siv liab)

4. Ob tus qauv khawm

5. Tsib lub xov hlau xiav (los qhia qhov tsis zoo tam sim no)

6. Peb lub xov hlau liab (los qhia qhov zoo tam sim no)

7. Ib lub txiv kab ntxwv-, ntsuab- thiab kab daj (PWM tswj cov xov hlau kom sib txawv ntawm 3 yam tseem ceeb)

8. Plaub lub xov hlau dawb (txhawm rau txuas lub Circuit Court)

9. Peb 10K ohm resistors (Xim av, Dub, Txiv Kab ntxwv, Kub)

Cov Cuab Yeej:

1. Lub laptop

2. Arduino IDE app (rub tawm los ntawm Microsoft Play store

LOS YOG

2. Arduino tsim lub vev xaib online (yog tias yog qhov koj nyiam)

3. Nimble tes

4. Google (lub vev xaib qhia tau pab kuv ntau)

5. Ua siab ntev; D

Kauj Ruam 2: Teeb Koj Lub Circuit Court Analog:

Teem Koj Li Circuit Court Analog
Teem Koj Li Circuit Court Analog

Qhov sib txawv ntawm Analog thiab Digital systems yog qhov Analog systems code rau lub xeev sib txawv xws li qhov sib txawv qhov ci ntawm LED thaum Digital tsuas yog cov lej rau ob lub xeev (xws li ON lossis OFF).

Lub voj voog no yog ib qho Analog vim tias lub hom phiaj yog ua kom lub teeb hloov pauv qhov ci ci, tsis yog mus ntxiv lossis tshem tawm.

Txhawm rau teeb tsa nws:

1. Siv ib lub xaim (rau qhov tsis zoo) xaim thiab ntsaws nws (ntawm Arduino) ntawm ib qho ntawm GND (hauv av) cov chaw nres nkoj ntawm cov chaw nres nkoj fais fab thiab txuas nws nyob txhua qhov chaw ntawm cov ntawv ci hauv kab ib sab ntawm qhov av tsis zoo xiav.

2. Siv ib lub xov tooj liab (zoo) xaim thiab txuas nws (ntawm Arduino) ntawm 5V chaw nres nkoj ntawm lub chaw nres nkoj fais fab thiab txuas nws mus rau kab ntawm kab rau ntawm lub khob cij uas nyob ib sab rau txoj kab liab liab zoo [Ua kom koj tus kheej paub tias yuav ua li cas rau lub khob cij teeb tsa tau teeb tsa thiab cov kab sib txuas tau zoo li cas.

3. Ntawm qhov kawg ntawm daim ntawv qhia zaub mov koj siv xiav thiab ib lub xaim liab los txuas cov kab hauv av.

4. Tom qab ntawd siv plaub lub xov hlau dawb los txuas cov kab hauv av ntawm ob qho tib si zoo thiab tsis zoo rau ob sab ntawm kab 30 ntawm nruab nrab (lawv yuav tsum txuas qhov sib txawv me me)

Kauj Ruam 3: Teeb tsa Lub Laub-khawm:

Teem Cov Laub-khawm
Teem Cov Laub-khawm

1. Tam sim no coj koj cov laub-khawm thiab txuas lawv kom nws hla qhov nruab nrab qhov sib txawv ntawm lub khob cij ntawm txhua lub ntsiab lus (Kuv nyiam tshaj tawm kuv cov khoom tawm me ntsis kom kuv tuaj yeem hloov pauv tau yooj yim dua thiab kho tau ntau yam.

2. Siv ob txoj hlua liab thiab txuas sab xis ntawm lub pob khawm tig rau koj nrog kab hauv av zoo.

3. Siv ob lub xov hlau xiav thiab txuas cov kab hauv av tsis zoo nrog rau kab nruab nrab ob peb kab sab laug ntawm ob txhais ceg sab laug ntawm lub laub-khawm, tawm qhov chaw rau cov tiv thaiv.

4. Tam sim no txuas tus 10K resistors (Xim av, Dub, Txiv Kab ntxwv, Kub) nrog ib txhais ceg hauv ib kab ib kab ib yam li xaim tsis zoo xaim thiab lwm ceg nyob hauv kab ib yam li sab laug ntawm lub laub-khawm

[Txhua yam no tseem txuas rau ntawm ib sab ntawm kev faib nyob hauv nruab nrab ntawm daim ntawv qhia zaub mov tshwj tsis yog cov nyees khawm hla qhov sib faib thiab cov xim dawb, liab- thiab xiav rau cov teeb tsa sib piv)

5. Tam sim no coj cov hlau daj thiab ntsuab thiab txuas rau sab laug ntawm sab tsis sib thooj ntawm qhov chaw faib nrog pins 9 thiab 11 [NB: Analog tsuas ua haujlwm ntawm tus pin 3, 5, 6, 9, 10 thiab 11]. Cov xov hlau no yog rau kev sib txuas lus nrog Arduino.

Kauj Ruam 4: Teeb LED:

Teeb LED
Teeb LED

1. Coj tus LED (xim uas koj xaiv) thiab muab tso rau ntawm ib sab ntawm qhov sib faib uas feem ntau ntawm koj cov kev sib txuas.

2. Siv ib lub xaim xaim thiab txuas cov kab xiav tsis zoo nrog rau kab ib yam li luv luv ceg (anode) ntawm LED [Lub voj voog yuav tsuas ua haujlwm yog tias kab xiav tsis zoo txuas nrog rau sab xis ntawm LED i.o.w. qhov anode.

3. Siv lwm 10K ohm resistor thiab txuas kab uas cathode (zoo ntev ceg ntawm LED) tau txuas nrog ib kab nyob ze ntawm tib sab ntawm qhov chaw faib.

4. Tam sim no coj cov kab xev txiv kab ntxwv thiab txuas tus tiv thaiv nrog tus pin 3 ntawm Arduino

Koj lub Circuit tam sim no ua tiav, txhua yam uas tam sim no yog npaj rau txhua yam

Kauj ruam 5: Programming Circuit:

Kuv yog tus tshiab rau txhua qhov no yog li thov zam txim rau kuv tsuas yog theej cov cai thiab tsis tsim cov vis dis aus …

Nov yog cov cai rau lub Circuit Court:

// Kuv (Altus Lourens) thawj qhov haujlwm: // Tsim nruab nrab ntawm 29 thiab 30th ntawm Lub Rau Hli, 2018

// NB rau kuv tus kheej: AnalogWrite tsuas ua haujlwm ntawm 3, 5, 6, 9, 10 thiab 11

// NB: Kev sib piv tau ua nrog cov xeev sib txawv, Digital tsuas yog ua haujlwm rau (HIGH) lossis tawm (LOW)

// LED yuav tso tawm

// pushbuttons yuav yog cov tswv yim

// pushButton1 yuav nce qhov ci nrog ib qho fadeAmount nrog txhua qhov nias

// pushButton2 yuav txo qhov ci ci nrog ib qho fadeAmount nrog txhua qhov nias

// qhov tsis hloov pauv, teeb tus lej PWM tus lej

const int ledPin = 3; // number of PWM LED pin

const koj fadeAmount = 50; // hloov qhov ci ci nrog txhua qhov thawb ntawm lub pob

const int buttonPin1 = 11;

const int buttonPin2 = 9; // tus lej ntawm tus lej khawm

// variable uas yuav hloov:

int qhov ci = 5; // pib ci ntsa iab ntawm LEDs

int buttonState1 = 0; // hais kom khawm pib ua LOW

int buttonState2 = 0; // hais kom khawm pib ua LOW

void teeb tsa () {

// muab koj cov cai teeb tsa ntawm no, kom khiav ib zaug:

// initialise tus pin LED raws li cov zis:

tus pinMode (ledPin, OUTPUT);

// pib lub pob nyem raws li cov tswv yim:

pinMode (buttonPin1, INPUT);

pinMode (buttonPin2, INPUT);

Serial.begin (9600); // ceev ntawm kev sib txuas lus hauv Circuit Court

}

// buttonPin1 yuav ua kom pom kev ci ntsa iab ntawm LED

// buttonPin2 yuav txo qhov ci ntawm LED

void voj () {

// muab koj cov cai tseem ceeb ntawm no, kom rov ua dua:

// teeb qhov ci ntawm tus pin 9:

analogWrite (ledPin, ci ntsa iab); // ci ntsa iab = 5, LED nyob

ci ntsa iab = txwv (qhov ci, 0, 255); // txwv qhov ci ntawm 0 thiab 255

// nyeem lub xeev tus lej khawm:

buttonState1 = digitalRead (buttonPin1);

buttonState2 = digitalRead (buttonPin2);

// xyuas yog tias cov nyees khawm tau raug nias:

// yog tias nws yog -> buttonState = HIGH:

// pushbutton1:

yog (buttonState1 == HIGH) {

ci ntsa iab = ci ntsa iab + fadeAmount; // nce qhov ci ci:

analogWrite (ledPin, ci ntsa iab + fadeAmount);

}

lwm tus {// ci ntsa iab nyob qis qis thiab LED tseem tawm:

analogWrite (ledPin, ci ntsa iab);

}

// pushbutton2:

yog (buttonState2 == HIGH) {

ci ntsa iab = ci ntsa iab - fadeAmount; // txo qhov ci ci:

analogWrite (ledPin, ci ntsa iab - fadeAmount);

}

lwm tus {

// ci ntsa iab nyob qis qis, tsis muaj qhov hloov pauv:

analogWrite (ledPin, ci ntsa iab);

}

Serial.print ("ci ntsa iab");

Serial.println (ci ntsa iab); }

Tam sim no koj tuaj yeem kho qhov nrawm ntawm kev sib txuas lus thiab ua si ib puag ncig nrog nws me ntsis kom txog thaum koj pom qhov nrawm uas ua haujlwm zoo tshaj plaws rau cov cuab yeej ntsuas saib [lub 9600 Baud tsuas yog tus qauv nrawm]

Pom zoo: