Cov txheej txheem:
- Kauj Ruam 1: Yuav Ua Li Cas I2c Ua Haujlwm
- Kauj ruam 2:
- Kauj ruam 3: Siv
- Kauj Ruam 4: Nyeem Tus Nqi
- Kauj Ruam 5: Nyeem Vale Los Ntawm Channel
- Kauj Ruam 6: Sau Tus Nqi
- Kauj Ruam 7: Nta Ntxiv
- Kauj Ruam 8: Piv Txwv Daim Duab Txuas
- Kauj ruam 9: Ua tsaug
Video: PCF8591 (i2c Analog I/O Expander) Kev Siv Yooj Yim Yooj Yim: 9 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:27
Lub tsev qiv ntawv siv i2c pcf8591 IC nrog arduino thiab esp8266.
Qhov IC no tuaj yeem tswj hwm (txog 4) cov tswv yim sib piv thiab/lossis 1 qhov tso tawm zoo ib yam li ntsuas qhov ntsuas hluav taws xob, nyeem tus nqi ntsuas hluav taws xob lossis ploj ib qho coj mus.
Muaj peev xwm nyeem tus nqi sib piv thiab sau tus nqi sib piv nrog tsuas yog 2 xaim (zoo meej rau ESP-01).
Kuv sim ua kom yooj yim siv IC no, nrog kev ua haujlwm tsawg kawg nkaus.
Koj tuaj yeem pom qhov hloov kho tshiab ntawm kuv qhov chaw
Kauj Ruam 1: Yuav Ua Li Cas I2c Ua Haujlwm
I2C ua haujlwm nrog nws ob lub xov hlau, SDA (kab ntawv cov ntaub ntawv) thiab SCL (kab kab ntawv).
Ob txoj kab no tau qhib-ntws, tab sis raug rub nrog cov neeg tawm tsam.
Feem ntau muaj ib tus tswv thiab ib lossis ntau tus qhev ntawm kab, txawm hais tias tuaj yeem muaj ntau tus tswv, tab sis peb yuav tham txog qhov ntawd tom qab.
Ob tus tswv thiab qhev tuaj yeem xa lossis txais cov ntaub ntawv, yog li ntawd, cov cuab yeej tuaj yeem nyob hauv ib ntawm plaub lub xeev no: tus tswv xa, tus tswv tau txais, tus xa tus qhev, tus qhev tau txais.
Kauj ruam 2:
Koj tuaj yeem nrhiav kuv lub tsev qiv ntawv ntawm no.
Txhawm rau rub tawm.
Nyem rau DOWNLOADS khawm nyob rau hauv kaum sab xis saum toj, hloov lub npe uas tsis tau nyem PCF8591.
Txheeb xyuas tias PCF8591 nplaub tshev muaj PCF8591.cpp thiab PCF8591.h.
Muab lub PCF8591 lub tsev qiv ntawv tais ceev tseg koj / tsev qiv ntawv / ntawv tais ceev tseg.
Koj yuav xav tsim lub tsev qiv ntawv subfolder yog nws yog koj thawj lub tsev qiv ntawv.
Rov pib dua IDE.
Kauj ruam 3: Siv
Tus tsim: koj yuav tsum hla qhov chaw nyob ntawm i2c (txhawm rau txheeb xyuas qhov chaw nyob siv phau ntawv qhia no I2cScanner)
PCF8591 (uint8_t chaw nyob);
rau esp8266 yog tias koj xav tau qhia SDA e SCL tus pin siv qhov no:
PCF8591 (uint8_t chaw nyob, uint8_t sda, uint8_t scl);
Kauj Ruam 4: Nyeem Tus Nqi
IC raws li koj tuaj yeem pom hauv daim duab muaj 4 analog input thiab 1 analog output.
Yog li txhawm rau nyeem tag nrho cov lus sib piv hauv ib qho kev thauj koj tuaj yeem ua tau (tus nqi yog 0 txog 255):
PCF8591:: AnalogInput ai = pcf8591.analogReadAll ();
Serial.print (ai.ain0); Serial.print (" -"); Serial.print (ai.ain1); Serial.print (" -"); Serial.print (ai.ain2); Serial.print (" -"); Serial.println (ai.ain3);
yog tias koj xav nyeem ib qho analog input lossis channel:
int ana = pcf8591.analogRead (AIN0); // nyeem analog 0
Kauj Ruam 5: Nyeem Vale Los Ntawm Channel
IC no muaj ntau hom kev nyeem thiab koj tuaj yeem siv Analog input lossis analog channel (thaum koj siv ib leeg nyeem cov lus sib piv thiab cov channel nyob hauv cov duab).
Piv txwv li txhawm rau nyeem tus nqi ntawm channel 0 hauv Ob qhov kev nkag siab sib txawv koj yuav tsum ua:
int ana = pcf8591.analogRead (CHANNEL0, TWO_DIFFERENTIAL_INPUT); // nyeem analog 0
Kauj Ruam 6: Sau Tus Nqi
Yog tias koj xav sau tus nqi sib piv koj yuav tsum ua (tus nqi yog 0 txog 255):
pcf8591.analogWrite (128);
Kauj Ruam 7: Nta Ntxiv
Cov yam ntxwv ntxiv yog nyeem qhov ntsuas hluav taws xob: Rau kev suav ntawm qhov hluav taws xob koj yuav tsum dhau qee qhov ntsuas:
- microcontrollerReferenceVoltage: tau txais qhov hluav taws xob los ntawm microcontroller voltage (tsuas yog AVR tsis muaj esp8266 rau esp 3.3v tsau)
- referenceVoltage: yog microcontrollerReferenceVoltage cuav coj tus nqi no Cov lus txib yog:
void voltageWrite (ntab tus nqi, bool microcontrollerReferenceVoltage = muaj tseeb, ntab referenceVoltage = 5.0);
Ntab voltageRead (uint8_t analogPin, bool microcontrollerReferenceVoltage = muaj tseeb, ntab referenceVoltage = 5.0);
Piv txwv yog:
pcf8591.voltageWrite (2.7); // 2.7Volts tso tawm
ncua (3000);
ntab ana0V = pcf8591.voltageRead (AIN0); // Nyeem qhov hluav taws xob los ntawm analog 0
Serial.println (ana0V);
Kauj Ruam 8: Piv Txwv Daim Duab Txuas
Kauj ruam 9: Ua tsaug
i2c project series (Sau):
- Kub ntsuas qhov ntsuas kub
- Analog nthuav dav
- Cov nthuav dav
- Zaub Zaub
Pom zoo:
D.I.Y YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM LOS NTAWM SCRAPS: 4 Cov Kauj Ruam (nrog Duab)
D.I.Y YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM LOS NTAWM SCRAPS: Hnub no kuv xav qhia yuav ua li cas kom pom lub teeb pom kev zoo los ntawm lub zog xa hluav taws xob tsis siv hluav taws xob los ntawm tus txhuam txhuam hniav thiab lub tshuab solenoid valve coils uas tau khaws los ntawm scrapyard.Ua ntej pib, thov saib cov vis dis aus hauv qab no:
Kev Ceeb Toom Hluav Taws Xob Siv Arduino [Hauv Qhov Yooj Yim Yooj Yim Yooj Yim]: 3 Kauj Ruam
Kev Ceeb Toom Hluav Taws Xob Siv Arduino [Hauv Ob Qes Yooj Yim Yooj Yim]: Puas yog koj tab tom nrhiav kom ua txoj haujlwm yooj yim thiab nthuav nrog Arduino uas nyob rau tib lub sijhawm tuaj yeem muaj txiaj ntsig tiag tiag thiab muaj peev xwm cawm txoj sia? tej yam tshiab thiab tshiab. Hauv kab ntawv no peb mus
Txoj Kev Yooj Yim thiab Yooj Yim Los Hloov Koj Lub Xauv Screen hauv 6 Cov Kauj Ruam Yooj Yim (Windows 8-10): 7 Kauj Ruam
Txoj Kev Yooj Yim thiab Yooj Yim Los Hloov Koj Lub Xauv Screen hauv 6 Cov Kauj Ruam Yooj Yim (Windows 8-10): Xav hloov pauv yam ntawm koj lub laptop lossis PC? Xav tau kev hloov pauv hauv koj qhov chaw? Ua raws cov kauj ruam no yooj yim thiab yooj yim kom ua tiav koj tus kheej lub computer ntsuas phoo
YUAV UA LI CAS YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM TSHAJ PLAWS YOOJ YIM: 4 Cov Kauj Ruam
YUAV UA LI CAS YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM YOOJ YIM TSHAJ PLAWS: Nyob zoo txhua tus hauv cov lus qhia no kuv yuav qhia koj yuav ua li cas kom yooj yim " SOIL DRYNESS SENSOR ". Qhuav ntawm cov av tau txheeb xyuas siv qhov taw qhia coj. Lub teeb ci wi
Ib qho yooj yim heev/yooj yim/Tsis yooj yim txoj hauv kev kom tib neeg/tib neeg/tsiaj/neeg hlau zoo li lawv muaj txias tiag tiag/Lub zeem muag tshav kub kub (Xim ntawm Koj Xaiv) Siv GIMP: 4 Cov Kauj Ruam
Ib qho yooj yim heev/yooj yim/Tsis yooj yim txoj hauv kev kom tib neeg/tib neeg/tsiaj/neeg hlau zoo li lawv muaj txias tiag tiag/Lub zeem muag tshav kub kub (Xim ntawm Koj Xaiv) Siv GIMP: Nyeem … lub npe