Cov txheej txheem:
- Kauj Ruam 1: Kev sib txuas ntawm DS1803
- Kauj ruam 2: Hais kom Byte
- Kauj Ruam 3: Tswj DS1803
- Kauj ruam 4: Teeb
- Kauj Ruam 5: Txoj Haujlwm
Video: DS1803 Dual Digital Potentiometer Nrog Arduino: 5 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:29
Kuv nyiam qhia kev siv DS1803 cov lauj kaub digital nrog Arduino. Qhov IC no muaj ob lub tshuab ntsuas hluav taws xob uas tuaj yeem tswj tau ob lub xov hlau sib txuas, rau qhov no kuv siv lub tsev qiv ntawv wire.h.
Qhov IC no tuaj yeem hloov pauv qhov qub potmeter analog. Hauv txoj kev no koj tuaj yeem tswj tau piv txwv li lub suab nrov lossis lub zog xa khoom.
Hauv cov lus qhia no kuv tswj qhov ci ntawm ob lub LED los qhia kev ua haujlwm.
Arduino suav cov mem tes ntawm lub cav hloov pauv thiab tso tus nqi hauv cov lauj kaub sib txawv [0] thiab lauj kaub [1]. Thaum koj thawb qhov hloov pauv ntawm tus lej cim, koj tuaj yeem hloov ntawm lub lauj kaub [0] thiab lauj kaub [1].
Tus nqi tiag ntawm lub lauj kaub tau nyeem rov qab los ntawm DS1803 thiab muab tso rau hauv qhov sib txawv potValue [0] thiab potValue [1] thiab nthuav tawm ntawm LCD.
Kauj Ruam 1: Kev sib txuas ntawm DS1803
Ntawm no koj tuaj yeem pom kev sib txuas ntawm DS1803. H yog sab siab ntawm lub hwj chim, L sab qis thiab W lub wiper. SCL thiab SDA yog cov tsheb npav sib txuas.
Nrog kev txuas A0, A1 thiab A2 koj tuaj yeem muab DS1803 nws tus kheej chaw nyob, ua li no koj tuaj yeem tswj hwm ntau yam khoom siv ntawm ib lub npav. Hauv kuv qhov piv txwv kuv tau muab DS1803 adres 0 los ntawm kev txuas txhua tus pin rau hauv av.
Kauj ruam 2: Hais kom Byte
Txoj kev DS1803 ua haujlwm tuaj yeem siv rau hauv cov lus txib byte. Thaum koj xaiv "sau potentiometer-0" ob qho potentiometers raug xaiv, thaum koj tsuas xav hloov kho potentiometer-0, koj tsuas yog yuav tsum xa thawj cov ntaub ntawv byte. "Sau potentiometer-1" tsuas yog kho potmeter-1. "Sau rau ob lub potentiometers" muab ob lub potentiometers tib tus nqi.
Kauj Ruam 3: Tswj DS1803
Kev tswj hwm byte (daim duab 3) muaj lub cim ntaus cim, qhov no nyob ib txwm zoo ib yam. Hauv kuv qhov piv txwv A0, A1 thiab A2 yog 0 vim tias peb xaiv adres los ntawm kev tso tag nrho A-pins rau hauv av. Qhov kawg R/W yuav raug teeb tsa 0 lossis 1 los ntawm cov lus txib "Wire.beginTransmission" thiab "Wire.requestFrom" hauv Arduino. Hauv daim duab 5 koj tuaj yeem pom tag nrho xov tooj. Kev nyeem xov tooj cua tau qhia hauv daim duab 4.
Kauj ruam 4: Teeb
Lub voj voog no qhia yuav ua li cas txuas txhua yam. Nokia LCD muaj nrog kev sib txuas sib txawv, nco ntsoov tias koj txuas koj li txoj cai. Tsis tas li ntawd lub cav encoder teb nws cov ntawv sib txawv, qee qhov muaj nyob ntawm tus pin nruab nrab lwm tus tsis. Kuv tau tso me ntsis lim network (470 Ohm resistor nrog 100nF cap) txhawm rau lim A thiab B cov teeb liab tso tawm ntawm tus encoder. Kuv xav tau lub lim dej no vim tias qhov tso tawm tau muaj suab nrov ntau. Kuv kuj tau tso lub sijhawm ncua deb hauv kuv qhov haujlwm kom tshem tawm qee lub suab nrov. Rau qhov seem kuv xav tias lub voj voog yog qhov tseeb. LCD tuaj yeem xaj ntawm Adafruit
Kauj Ruam 5: Txoj Haujlwm
Rau kev siv 2-xaim tsheb npav kuv suav nrog Wire.h lub tsev qiv ntawv. Txhawm rau siv LCD Kuv suav nrog Adafruit lub tsev qiv ntawv uas koj tuaj yeem rub tawm los ntawm https://github.com/adafruit/Adafruit-PCD8544-Nokia-5110-LCD-library tseem muaj Adafruit_GFX.h lub tsev qiv ntawv muaj nyob ntawm no https:// github. com/adafruit/Adafruit-GFX-Lub Tsev Qiv Ntawv.
#suav nrog
#suav nrog
#suav nrog
Adafruit_PCD8544 zaub = Adafruit_PCD8544 (7, 6, 5, 4, 3);
Ntawm no koj tuaj yeem pom txhua qhov sib txawv. Tswj byte thiab hais kom ua byte raws li tau hais ua ntej. Lub deBounceTime tuaj yeem hloov kho raws li lub suab nrov ntawm koj tus lej cim.
byte lauj kaub [2] = {1, 1}; byte controlByte = B0101000; // 7 khoom, byte commandByte = B10101001; // 2 qhov kawg yog xaiv lub ntsuas ntsuas. byte potValue [2]; int kuv = 0; int deBounceTime = 10; // Kho tus nqi no nyob ntawm lub suab nrov const int encoder_A = 8; const int encoder_B = 9; const int buttonPin = 2; unsigned ntev newDebounceTime = 0; unsigned ntev oldTime; boolean nias = 0; boolean suav = 1;
Hauv kev teeb tsa kuv txhais cov pins zoo thiab muab cov ntawv zoo li qub tso rau ntawm LCD
teeb tsa tsis muaj dabtsis () {Wire.begin (); Serial.begin (9600); pinMode (encoder_A, INPUT); pinMode (encoder_B, INPUT); pinMode (buttonPin, INPUT); newDebounceTime = millis ();
display.begin ();
display.setContrast (50); display.clearDisplay (); display.setTextSize (1); display.setTextColor (BLACK); display.setCursor (0, 10); display.println ("POT 1 ="); display.setCursor (0, 22); display.println ("POT 2 ="); display.display ();
}
Hauv lub voj kuv xub tshawb xyuas yog tias ncua sijhawm ntau dua 500ms, yog tias yog lub LCD tau hloov kho tshiab. Yog tias tsis yog lub pob ntawm tus encoder raug tshuaj xyuas. Yog tias nias lub toggleBuffer tau hu. Tom qab qhov no tau txheeb xyuas qhov encoder. Yog tias cov tswv yim 0 tsawg (kev ntsuas ntsuas pom) Kuv tshawb xyuas B, yog tias cov tswv yim B yog 0 Kuv nce lub lauj kaub , lwm tus kuv txo qis. Tom qab qhov no tus nqi yuav raug xa mus rau DS1803 ntawm wire.write.
void voj () {
ncua ();
yog (digitalRead (buttonPin) == 1 && (nias == 0)) {toggleBuffer ();} yog (digitalRead (buttonPin) == 0) {nias = 0;}
yog (digitalRead (encoder_A) == 0 && suav == 0 && (millis () - newDebounceTime> deBounceTime)) {yog (digitalRead (encoder_B) == 0) {lauj kaub ++; yog (lauj kaub > 25) {lauj kaub = 25;}} ntxiv {lauj kaub -; if (lauj kaub <1) {lauj kaub = 1;}} suav = 1; newDebounceTime = millis ();
Wire.beginTransmission (controlByte); // pib kis
Wire.write (commandByte); // xaiv potmeters Wire.write (lauj kaub [0] * 10); // xa 1st byte ntawm cov ntaub ntawv potmeter Wire.write (lauj kaub [1] * 10); // xa thib ob byte ntawm cov ntaub ntawv ntsuas lub xov tooj Wire.endTransmission (); // tsis txhob xa lwm tus yog tias (digitalRead (encoder_A) == 1 && digitalRead (encoder_B) == 1 && suav == 1 && (millis () - newDebounceTime> deBounceTime)) {suav = 0; newDebounceTime = millis (); }}
tsis muaj dab tsi toggleBuffer () {nias = 1; yog (kuv == 0) {kuv = 1;} lwm tus {kuv = 0;}}
Ua ntej kuv tshem thaj chaw uas kuv yuav tsum sau qhov txawv. Kuv ua qhov no los kos ib lub duab plaub hauv cheeb tsam no. Tom qab ntawd kuv sau qhov hloov pauv rau ntawm qhov screen.
void writeToLCD () {Wire.requestFrom (controlByte, 2); potValue [0] = Wire.read (); // nyeem thawj potmeter byte potValue [1] = Wire.read (); // nyeem thib ob potmeter byte display.fillRect (40, 0, 40, 45, WHITE); // pom qhov txawv txav ntawm lub vijtsam LCD.setCursor (40, 10); display.print (potValue [0]); // sau tus lej thib 1 rau tus lej LCD.setCursor (40, 22); display.print (potValue [1]); // sau tus lej thib ob rau tus lej LCD.setCursor (60, (10 + i * 12)); display.print ("<"); display.display (); }
void interval () {// ncua sij hawm timer los sau cov ntaub ntawv rau LCD yog ((millis () - oldTime)> 500) {writeToLCD (); oldTime = millis (); }}
Pom zoo:
Dual Xim Bar Teeb Nrog CircuitPython: 5 Cov Kauj Ruam (nrog Duab)
Dual Color Bar Graph With CircuitPython: Kuv pom qhov LED bar-teeb ntawm Pimoroni qhov chaw thiab xav tias nws yuav yog qhov pheej yig thiab lom zem txoj haujlwm thaum ua covid-19 kaw nws muaj 24 LEDS, liab thiab ntsuab, hauv txhua qhov ntawm nws 12 ntu, yog li hauv kev xav koj yuav tsum muaj peev xwm nthuav tawm r
Tswj LED Brightness Nrog Potentiometer Nrog Arduino: 3 Kauj Ruam
Tswj LED Brightness Nrog Potentiometer Nrog Arduino: Hauv txoj haujlwm no, peb yuav tswj qhov ci ntawm LED siv qhov sib txawv tsis kam muab los ntawm potentiometer. Nov yog txoj haujlwm yooj yim heev rau tus pib tab sis nws yuav qhia koj ntau yam txog potentiometer thiab LED ua haujlwm uas yuav tsum tau ua kom muaj kev tshaj tawm
MCP41HVX1 Digital Potentiometer rau Arduino: 10 Kauj Ruam (nrog Duab)
MCP41HVX1 Digital Potentiometer rau Arduino: MCP41HVX1 tsev neeg ntawm digital potentiometers (aka DigiPots) yog cov cuab yeej siv uas ua raws li kev ua haujlwm ntawm analog potentiometer thiab raug tswj los ntawm SPI. Ib qho piv txwv thov yuav hloov lub pob qhov rooj ntawm koj lub tso suab nrog DigiPot uas yog
Dual 7 -ntu Cov Lus Qhia Tswj los ntawm Potentiometer hauv CircuitPython - Qhia tawm ntawm Kev Ua Phem Tsis Pom Kev: 9 Kauj Ruam (nrog Duab)
Dual 7-ntu Cov Lus Qhia Tswj los ntawm Potentiometer hauv CircuitPython-Qhia tawm ntawm Kev Ua Phem Tsis Pom Kev: Qhov haujlwm no siv lub zog ntsuas los tswj cov zaub ntawm ob peb ntawm 7-ntu LED qhia (F5161AH). Raws li lub pob qhov ntsuas hluav taws xob tau tig lub teeb pom kev hloov pauv hauv thaj tsam 0 txog 99. Tsuas yog ib qho LED tau teeb nyob rau txhua lub sijhawm, luv luv, tab sis
LED Dimmer Nrog Potentiometer: 5 Kauj Ruam (nrog Duab)
LED Dimmer Nrog Potentiometer: Nov yog cov lus qhia uas qhia koj yuav siv lub hwj chim li cas kom dim ib qho LED