Cov txheej txheem:
- Kauj Ruam 1: Nkag Siab Cov Ntaub Ntawv Tso Tawm
- Kauj ruam 2: Tsim Circuit Court
- Kauj Ruam 3: Sau Txoj Cai
Video: Rotary Encoder - Nkag siab thiab Siv Nws (Arduino/lwm tus -Controller): 3 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
Lub tshuab hluav taws xob hloov pauv yog lub tshuab hluav taws xob uas hloov cov lus tsa suab tig mus rau digital lossis analog cov ntaub ntawv. Nws tuaj yeem tig lub moos los yog clockwise. Muaj ob hom kev hloov pauv ntawm tus lej: Tsis meej thiab txheeb ze (nce ntxiv) encoders.
Thaum qhov kev lees paub meej meej tso tawm tus nqi sib npaug rau lub kaum ntse ntse tam sim no, ib qho ntxiv tus lej nkag mus tso tawm cov kauj ruam ntawm tus ncej thiab nws cov kev taw qhia. (Hauv qhov no peb muaj cov lej nkag mus ntxiv)
Cov encoders teb tau dhau los ua neeg nyiam vim tias koj tuaj yeem siv ob lub zog hauv ib qho qauv hluav taws xob: Ib qho yooj yim hloov rau kev lees paub kev ua haujlwm thiab cov encoder teb rau kev taw qhia, piv txwv li. los ntawm cov ntawv qhia zaub mov.
Ib qho kev sib hloov zuj zus ntxiv encoder tsim ob lub cim tso tawm thaum nws lub taub hau tig. Nyob ntawm qhov kev taw qhia, ib qho ntawm cov cim qhia rau lwm tus. (saib hauv qab)
Kauj Ruam 1: Nkag Siab Cov Ntaub Ntawv Tso Tawm
Raws li koj tuaj yeem pom thaum tus lej nkag nkag pib tig raws lub moos, cov zis A poob mus rau LOW ua ntej thiab cov zis B ua raws nws. Nyob rau hauv cov lus taw qhia-clockwise kev ua haujlwm tig rov qab.
Tam sim no peb tsuas yog yuav tsum ua qhov no ntawm peb tus tswj hwm (Kuv siv Arduino Nano).
Kauj ruam 2: Tsim Circuit Court
Raws li kuv tau piav qhia ua ntej cov txiaj ntsig tsim tau HIGH thiab LOW flank. Txhawm rau kom tau HIGH huv ntawm cov ntaub ntawv tus pin A thiab B ntawm µController peb yuav tsum ntxiv Pull-Up resistors. Tus Pin C feem ntau mus ncaj nraim rau hauv av rau LOW flank.
Txhawm rau kom tau txais cov ntaub ntawv hais txog kev hloov pauv sab hauv (thawb-khawm) peb yuav siv lwm ob tus pin. Ib ntawm lawv mus rau VCC thiab lwm qhov mus rau cov ntaub ntawv Pin ntawm µController. Peb kuj yuav tsum tau ntxiv Pull-Down Resistor rau cov ntaub ntawv tus pin kom tau txais LOW huv.
Nws kuj tseem tuaj yeem siv sab hauv Rub-Up thiab Pull-Down resistors ntawm koj tus tswj hwm!
Hauv kuv qhov teeb meem pinout zoo li:
- +3, 3V => +3, 3V (Arduino) (kuj +5V tau)
- GND => GND (Arduino)
- A => Pin 10
-
IB =>
Tus Pin
11
- C => GND
-
SWV =>
Tus Pin
12
Kauj Ruam 3: Sau Txoj Cai
pin pin = 10; // internal switch A int pinB = 11; // internal switch B int pinSW = 12; // hloov (nias Encoder) int encoderPosCount = 0; // pib ntawm xoom, hloov yog tias koj xav tau
int qhov chaw;
bool hloov pauv; koj mrotateLast; koj mrotate;
void teeb tsa () {
int mrotateLast = digitalRead (pinA); Serial.begin (9600); ncua (50); }
lub voj void () {readencoder (); yog (readswitch () == 1) {Serial.println ("Hloov = 1"); }}
koj readencoder () {
mrotate = digitalRead (pinA); yog (mrotate! = mrotateLast) {// pob qhov rooj yog tig yog (digitalRead (pinB)! = mrotate) {// hloov A hloov ua ntej -> rotating clockwise encoderPosCount ++; Serial.println ("rotated clockwise"); } lwm tus {// hloov B hloov ua ntej-> tig lub moos xauv moos encoderPosCount--; Serial.println ("tig rov qab moos"); }
Serial.print ("Txoj Haujlwm Encoder:"); Serial.println (encoderPosCount); Serial.println (""); } mrotateLast = mrotate; rov encoderPosCount; } bool readswitch () {
yog (digitalRead (pinSW)! = 0) {// hloov tau nyem
thaum (digitalRead (pinSW)! = 0) {} // hloov tam sim no nias switchval = 1; } lwm tus {switchval = 0;} // hloov tsis hloov siab rov qab hloov pauv; }
Tam sim no koj tuaj yeem tig tus lej cim thiab qhov sib txawv ntawm tus lej encoderPosCount yuav suav tau yog tias koj tig clockwise thiab suav rov qab yog tias koj tig counter clockwise.
Nws yog! Yooj yim thiab muaj txiaj ntsig.
Xav tias hloov pauv thiab ua qhov chaws. Koj tuaj yeem siv nws hauv koj qhov project.
Kuv tseem yuav tso qhov project LED uas kuv siv tus lej nkag los teeb qhov ci ntawm kuv cov LEDs.
Pom zoo:
Rotary Encoder: Nws Ua Haujlwm Li Cas thiab Yuav Siv Li Cas Nrog Arduino: 7 Cov Kauj Ruam
Rotary Encoder: Nws Ua Haujlwm Li Cas thiab Yuav Siv Li Cas Nrog Arduino: Koj tuaj yeem nyeem qhov no thiab lwm yam kev qhia zoo ntawm ElectroPeak lub vev xaib raug cai Ua ntej, koj yuav pom qee cov ntaub ntawv hais txog kev hloov pauv tus lej, thiab tom qab ntawd koj yuav kawm paub yuav ua li cas
Raspberry Pi Oled Moos Saib Nws hnov Nws thiab hnov Nws: 5 Kauj Ruam (nrog Duab)
Raspberry Pi Oled Clock Watch Nws hnov Nws thiab hnov Nws: Qhov no yog lub moos ntse uas qhia lub sijhawm ntawm cov zaub OLED thiab tseem koj tuaj yeem hnov lub sijhawm nyob rau lub sijhawm sib txawv ntawm lub sijhawm uas yog pab puv rau qhov muag tsis pom thiab Nws tseem hloov cov xim coj nrog lub sijhawm zoo li lub teeb nyob rau yav tsaus ntuj lub teeb nyob rau yav tsaus ntuj mus txiv kab ntxwv rau daj thiab zoo li t
Yuav Ua Li Cas Tau Txais Cov Nkauj Los Ntawm Txhua Qhov (Haha) Lub Vev Xaib (Ntev Li Koj Tau hnov Nws Koj Yuav Tau Txais Nws Ok Zoo Yog Nws Tau Ntxig Hauv Flash Koj Yuav Tsis Muaj Peev Xwm) EDITED !!!!! Ntxiv Info: 4 Cov Kauj Ruam
Yuav Ua Li Cas Tau Txais Cov Nkauj Los Ntawm Txhua Qhov (Haha) Lub Vev Xaib (Ntev Li Koj Tau hnov Nws Koj Yuav Tau Txais Nws … Ok Zoo Yog Nws Tau Ntxig Hauv Flash Koj Yuav Tsis Muaj Peev Xwm) EDITED !!!!! Ntxiv Cov Lus Qhia: yog tias koj tau mus rau lub vev xaib thiab nws ua nkauj nkauj uas koj nyiam thiab xav tau nws ntawm no yog cov lus qhia rau koj tsis yog kuv qhov txhaum yog tias koj cuam tshuam qee yam (tsuas yog txoj hauv kev nws yuav tshwm sim yog tias koj pib tshem cov khoom yam tsis muaj laj thawj. ) Kuv tuaj yeem tau txais cov nkauj rau
Txuas tus Ipod lossis Lwm Tus Neeg Siv Mp3 rau Cov Hais Lus Hauv Tsev Ib Yam Tsis Muaj Tus Nqi kim thiab Bulky Amplifier!: 4 Cov Kauj Ruam
Txuas tus Ipod lossis Lwm Tus Neeg Siv Mp3 rau Cov Hais Lus Hauv Tsev Ib Yam Tsis Muaj Tus Nqi kim thiab Bulky Amplifier!: Koj puas muaj cov hais lus tso suab ntxiv, uas yog tuaj nrog cheep stereos uas tawg lossis koj tsuas yog muaj yam tsis muaj laj thawj? Hauv Cov Lus Qhia Kuv yuav qhia koj yuav ua li cas koj tuaj yeem txuas lawv rau txhua tus neeg siv Mp3 lossis ib lub cuab yeej twg nrog lub suab nrov
Cov Neeg Hais Lus Tsis Txaus Dej Uas Ntab - " Nws Ntws, Nws Totes thiab Nws Pob Zeb Sau Ntawv! &Quot;: 7 Cov Kauj Ruam (nrog Duab)
Cov Neeg Hais Lus Tsis Txaus Dej Uas Ntab - " Nws Ntws, Nws Totes thiab Nws Pob Zeb Sau Ntawv! ). Peb yuav ntab hauv tus dej, lossis txuas kab rau ntawm ntug dej kom peb cov ntab nyob ntawm qhov chaw peb nyob. Txhua tus neeg