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 - ADXL345 3 -Axis Accelerometer Java Qhia: 4 Kauj Ruam
2024 Tus sau: John Day | [email protected]. Kawg hloov kho: 2024-01-30 09:25
ADXL345 yog qhov me me, nyias, lub zog loj, 3-axis accelerometer nrog kev ntsuas siab (13-ntsis) ntsuas txog li g 16 g. Cov ntaub ntawv tso tawm digital yog ua raws li 16-ntsis twos ua tiav thiab siv tau los ntawm I2 C digital interface. Nws ntsuas qhov kev nrawm nrawm ntawm lub ntiajteb txawj nqus hauv kev thov qaij-nkag siab, nrog rau kev nrawm nrawm los ntawm kev txav lossis poob siab. Nws qhov kev daws teeb meem siab (3.9 mg/LSB) ua rau ntsuas ntsuas qhov xav tau hloov qis dua 1.0 °. Nov yog nws ua qauv qhia nrog raspberry pi siv java code.
Kauj Ruam 1: Yam Koj Xav Tau..
1. Raspberry Pi
2. ADXL345
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 kawg ntawm I2C cable rau ADXL345 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:
Java code rau ADXL345 tuaj yeem rub tawm los ntawm peb GitHub chaw cia khoom- Dcube Store
Nov yog qhov txuas rau tib yam:
github.com/DcubeTechVentures/ADXL345
Peb tau siv pi4j tsev qiv ntawv rau java code, cov kauj ruam rau nruab pi4j ntawm raspberry pi tau piav qhia ntawm no:
pi4j.com/install.html
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 ua haujlwm.
// ADXL345
// Cov cai no tau tsim los ua haujlwm nrog ADXL345_I2CS I2C Mini Module muaj nyob hauv Dcube Store.
ntshuam com.pi4j.io.i2c. I2CBus;
ntshuam com.pi4j.io.i2c. I2CDevice;
ntshuam com.pi4j.io.i2c. I2CFactory;
ntshuam java.io. IOException;
pej xeem chav ADXL345
{
pej xeem zoo li qub tsis muaj dab tsi tseem ceeb (Txoj hlua args ) cuam tshuam zam
{
// Tsim I2C npav
I2CBus Bus = I2CFactory.getInstance (I2CBus. BUS_1);
// Tau txais I2C ntaus ntawv, ntaus ntawv I2C chaw nyob yog 0x53 (83)
I2CDevice ntaus ntawv = Bus.getDevice (0x53);
// Xaiv Bandwidth tus nqi sau npe
// Hom qub, Cov ntaub ntawv tawm tus nqi = 100 Hz
device.write (0x2C, (byte) 0x0A);
// Xaiv lub hwj chim tswj npe
// Auto-sleep lov tes taw
ntaus ntawv.write (0x2D, (byte) 0x08);
// Xaiv cov ntaub ntawv sau npe
// Kev ntsuas tus kheej xiam oob qhab, 4-xaim interface, Kev daws teeb meem tag nrho, thaj tsam = +/- 2g
device.write (0x31, (byte) 0x08);
Xov.sleep (500);
// Nyeem 6 bytes ntawm cov ntaub ntawv
// xAccl lsb, xAccl msb, yAccl lsb, yAccl msb, zAccl lsb, zAccl msb
byte cov ntaub ntawv = tshiab byte [6];
cov ntaub ntawv [0] = (byte) device.read (0x32);
cov ntaub ntawv [1] = (byte) device.read (0x33);
cov ntaub ntawv [2] = (byte) device.read (0x34);
cov ntaub ntawv [3] = (byte) device.read (0x35);
cov ntaub ntawv [4] = (byte) device.read (0x36);
cov ntaub ntawv [5] = (byte) device.read (0x37);
// Hloov cov ntaub ntawv mus rau 10-ntsis
int xAccl = ((data [1] & 0x03) * 256 + (data [0] & 0xFF));
yog (xAccl> 511)
{
xAccl -= 1024;
}
int yAccl = ((cov ntaub ntawv [3] & 0x03) * 256 + (data [2] & 0xFF));
yog (yAccl> 511)
{
yAccl -= 1024;
}
int zAccl = ((cov ntaub ntawv [5] & 0x03) * 256 + (data [4] & 0xFF));
yog (zAccl> 511)
{
zAccl -= 1024;
}
// Cov ntaub ntawv tso tawm rau lub vijtsam
System.out.printf ("Kev nrawm hauv X-Axis: %d %n", xAccl);
System.out.printf ("Kev nrawm hauv Y-Axis: %d %n", yAccl);
System.out.printf ("Acceleration in Z-Axis: %d %n", zAccl);
}
}
Kauj Ruam 4: Cov ntawv thov:
ADXL345 yog qhov me me, nyias, lub zog loj, 3-axis accelerometer uas tuaj yeem ua haujlwm hauv Tes, Cov cuab yeej siv kho mob thiab lwm yam.
Pom zoo:
Cov Lus Qhia Qhia: 3 Kauj Ruam
Cov Lus Qhia Ua Ntej: Xijpeem koj ua haujlwm, nws taug kev, taug kev, caij tsheb kauj vab lossis txawm tias tsav tsheb, koj tuaj yeem sau cov kev uas koj taug. Tom qab ntawd koj tuaj yeem faib cov kev no nrog phooj ywg thiab tsev neeg. Ib qho ntxiv, koj tuaj yeem siv txoj hauv kev kaw tseg los ntxiv qhov chaw rau txhua daim duab uas koj tuaj yeem h
LED Qhov Taw Qhia Qhov Taw Qhia Tus Menyuam: 5 Kauj Ruam (nrog Duab)
LED Qhov Taw Qhia Qhov Taw Qhia Tus dev: Kuv ib txwm coj kuv tus dev Rusio mus taug kev thaum lub hnub poob qis kom nws tuaj yeem ua si yam tsis tau kub heev. Qhov teeb meem yog tias thaum nws tawm ntawm txoj hlua qee zaum nws tau zoo siab heev thiab ua haujlwm ntau dua li nws yuav tsum thiab nrog lub teeb qis thiab lwm tus dev
2019 FRC Sau Ntawv Qhia Txog Kev Cob Qhia Tsav Tsheb (Java): 5 Kauj Ruam
2019 FRC Sau Ntawv Qhia Txog Kev Cob Qhia Tsav Tsheb yooj yim (Java): Cov lus qhia no YUAV TSHUAJ TUG DATE! Txawm hais tias nws tsis dhau los tseem muaj qee yam uas koj tuaj yeem kawm txog nws zoo li yuav ua li cas thiaj ua tau cov chav kawm thiab sau cov cai
Kuv Me Me Whoop: Daim Ntawv Qhia Whoop + Cov Lus Qhia thiab Cov Lus Qhia: 8 Kauj Ruam
Kuv Me Me Whoop: Daim Ntawv Qhia Whoop + Cov Lus Qhia thiab Cov Lus Qhia: Kev Ceeb Toom: Tam sim no koj tab tom nkag mus rau kuv thawj qhov kev qhia, thiab koj yuav ntsib ntau yam kev ruam thiab tsis muaj phiaj xwm thiab/lossis txuj ci. Paub txog qhov no yog kuv tus kheej Tiny Whoop teeb tsa uas kuv siv txhua hnub, yog li kuv xav tias kuv yuav qhia nws. Nws yog phooj ywg mus ncig (tsis muaj
Yuav Ua Li Cas Ua Tus Qhia Qhia thiab Qhia: 8 Kauj Ruam
Yuav Ua Li Cas Nthuav Qhia Qhia thiab Qhia: Nov yog phau ntawv qhia rau kev ua Qhia Qhia thiab Qhia. Nws yog qhov tseem ceeb tshaj plaws ntawm cov xwm txheej muaj nyob rau Hnub Friday, Peb Hlis 9, 2007, tab sis kuj tseem yog qhov tshwm sim yav dhau los ntawm qhov xwm txheej no, Squid Labs Lub Teeb Pom Kev Zoo. Lub hom phiaj ntawm Kev Qhia thiab Xov Tooj