Cov txheej txheem:
- Kauj Ruam 1: Yam Koj Xav Tau..
- Kauj Ruam 2: Kev Sib Txuas:
- Kauj ruam 3: Code:
- Kauj Ruam 4: Cov ntawv thov:
Video: Raspberry Pi - PCA9536 Cov tswv yim/tso tawm Expander Python Tutorial: 4 Cov Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:26
PCA9536 yog 8-tus pin CMOS ntaus ntawv uas muab 4 lub ntsis ntawm Lub Hom Phiaj Dav Dav thaum uas tig mus Kev Tawm/Tawm (GPIO) nthuav dav rau I2C-npav/SMBus daim ntawv thov. Nws suav nrog 4-ntsis Kev teeb tsa sau npe los ua haujlwm lub hom phiaj ntawm kev xaiv tswv yim lossis xaiv tawm, 4-ntsis Kev Nkag Nkag Chaw Nkag Nkag, 4-ntsis Chaw Tso Tawm Chaw Tso Npe thiab 4-ntsis Polarity Inversion register active HIGH lossis nquag ua haujlwm LOW. Nov yog nws qhov ua piv txwv nrog raspberry pi siv tus lej nab npawb.
Kauj Ruam 1: Yam Koj Xav Tau..
1. Raspberry Pi
2. PCA9536
3. I²C Cable
4. I²C Shield rau Raspberry Pi
5. Ethernet Cable
Kauj Ruam 2: Kev Sib Txuas:
Siv daim I2C daim thaiv rau raspberry pi thiab maj mam thawb nws hla gpio pins ntawm raspberry pi.
Tom qab ntawd txuas ib qho kawg ntawm I2C cable rau PCA9536 sensor thiab lwm qhov kawg rau I2C daim ntaub thaiv.
Kuj txuas Ethernet cable rau pi lossis koj tuaj yeem siv WiFi module.
Kev sib txuas tau qhia hauv daim duab saum toj no.
Kauj ruam 3: Code:
Tus nab npawb nab npawb rau PCA9536 tuaj yeem rub tawm los ntawm peb qhov chaw cia khoom github- DCUBE Store.
Nov yog qhov txuas
Peb tau siv SMBus lub tsev qiv ntawv rau sej code, cov kauj ruam rau nruab SMBus ntawm raspberry pi tau piav qhia ntawm no:
pypi.python.org/pypi/smbus-cffi/0.5.1
Koj tseem tuaj yeem luam cov cai los ntawm no, nws tau muab raws li hauv qab no:
# Faib nrog daim ntawv tso cai yuav dawb.
# Siv nws txhua txoj hauv kev uas koj xav tau, muaj txiaj ntsig lossis pub dawb, muab nws haum rau hauv daim ntawv tso cai ntawm nws cov haujlwm sib txuam.
# TSA 9536
# Txoj cai no yog tsim los ua haujlwm nrog PCA9536_I2CIO I2C Mini Module #
ntshuam smbus
lub sij hawm ntshuam
# Tau I2C npav
npav = smbus. SMBus (1)
# PCA9536 chaw nyob, 0x41 (65)
# Xaiv kev teeb tsa sau npe, 0x03 (03)
# 0xFF (255) Txhua tus pin teeb tsa raws li cov tswv yim
bus.write_byte_data (0x41, 0x03, 0xFF)
# Tso tawm rau lub vijtsam
luam tawm "Txhua Lub Xeev Pins yog HIGH"
sijhawm.s pw (0.5)
# PCA9536 chaw nyob, 0x41 (65)
# Nyeem cov ntaub ntawv rov qab los ntawm 0x00 (00), 1 byte
cov ntaub ntawv = bus.read_byte_data (0x41, 0x00)
# Hloov cov ntaub ntawv mus rau 4-ntsis
data = (cov ntaub ntawv & 0x0F)
rau kuv hauv ntau (0, 4):
yog (cov ntaub ntawv & (2 ** i)) == 0:
luam tawm "I/O Pin %d Lub Xeev LOW" %i
lwm tus:
luam tawm "I/O Pin %d Lub Xeev yog HIGH" %i
sijhawm.s pw (0.5)
Kauj Ruam 4: Cov ntawv thov:
PCA9536 tuaj yeem ua haujlwm ua I/O nthuav dav. Nws muab kev daws teeb meem yooj yim thaum xav tau cov tswv yim ntxiv/tso tawm. Feem ntau nws tau ua haujlwm hauv cov kab ke uas xav tau kev nthuav dav rau ACPI lub zog hloov pauv, ntsuas ntsuas, thawb khawm, LEDs, kiv cua, thiab lwm yam.
Pom zoo:
Kho Ob Chav Tawm Tawm Tawm Tawm Tawm Cov Khoom Siv Hluav Taws Xob: 10 Cov Kauj Ruam (nrog Duab)
Kho Ob Chav Tawm Tawm Tawm Tawm Tawm Tawm Cov Khoom Siv Hluav Taws Xob: Nta: AC-DC Hloov pauv ob npaug tso tawm qhov hluav taws xob (Zoo-Hauv av-Tsis Zoo) Kho txoj kab zoo thiab tsis zoo Tsuas yog Ib Leeg Ib Leeg AC hloov pauv cov suab nrov (20MHz-BWL, tsis muaj thauj khoom): Ib puag ncig 1.12mVpp Tsawg suab nrov thiab cov txiaj ntsig ruaj khov (zoo tagnrho
Cov Lus Qhia Ua Kom Koj Lub Tswv Yim Lub Tswv Yim Muaj Tseeb: 6 Cov Kauj Ruam (nrog Duab)
Cov Lus Qhia Kom Ua Koj Lub Tswv Yim Lub Tswv Yim: Qhov tseem ceeb tshaj plaws ntawm txoj haujlwm ua tiav yog muaj lub tswv yim zoo tiag tiag, tab sis qee zaum lub tswv yim yog qhov yooj yim! Tom qab ntawd los ua haujlwm nyuaj hauv kev ua qhov flash flash ntawm kev txawj ntse rau qee yam uas tib neeg " ooh " thiab " ah " ov
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
Yuav Ua Li Cas Txuas Lub Laub Khawm Nrog Suab Tawm Tswv Yim thiab Tso Tawm: 13 Kauj Ruam
Yuav Ua Li Cas Txuas Lub Laub Khawm Nrog Lub Suab Tawm Tawm thiab Tawm Tawm: Lub laub khawm yog ib qho ntawm cov hauv paus tseem ceeb rau kev ntes koj qhov kev ua. Koj tuaj yeem thawb lub pob kom ua ib yam dab tsi. Muaj ntau txoj hauv kev los siv cov nyees khawm hauv koj cov phiaj xwm (piv txwv li nyiag nkas nas thiab keyboard, lossis Arduino, gainer, MCK). Tsi
Yuav Ua Li Cas Txuas Lub Sensor Nrog Lub Suab Tso Tawm thiab Tso Tawm: 15 Cov Kauj Ruam
Yuav Ua Li Cas Txuas Lub Sensor Nrog Lub Suab Tawm Tswv Yim thiab Tso Tawm: Lub sensor yog ib qho ntawm cov hauv paus tseem ceeb rau kev ntes lub cev ib puag ncig. Koj tuaj yeem tau txais qhov hloov pauv ntawm lub teeb nrog CDS photocell, koj tuaj yeem ntsuas qhov chaw nrog lub ntsuas qhov deb, thiab koj tuaj yeem ntes koj lub zog nrog lub ntsuas cua. Muaj lwm yam