Cov txheej txheem:

Yuav Ntsuas Li Cas Nrog MPU-6050 (GY-521): 3 Kauj Ruam
Yuav Ntsuas Li Cas Nrog MPU-6050 (GY-521): 3 Kauj Ruam

Video: Yuav Ntsuas Li Cas Nrog MPU-6050 (GY-521): 3 Kauj Ruam

Video: Yuav Ntsuas Li Cas Nrog MPU-6050 (GY-521): 3 Kauj Ruam
Video: Siv ntsev ntsuas paub tias muaj me nyuam 2024, Kaum ib hlis
Anonim
Yuav Ntsuas Li Cas Nrog MPU-6050 (GY-521)
Yuav Ntsuas Li Cas Nrog MPU-6050 (GY-521)

Hauv Cov Lus Qhia no, peb yuav ntsuas lub kaum ntse ntse nrog Arduino. Peb xav tau qee cov xov hlau, Arduino UNO thiab GY-521 (MPU-6050) txhawm rau ntsuas lub kaum ntse ntse.

Kauj Ruam 1: Txuas MPU-6050 rau Arduino UNO

Txuas MPU-6050 rau Arduino UNO
Txuas MPU-6050 rau Arduino UNO

Peb xav tau qee tus txiv neej-poj niam cable, Arduino UNO thiab GY-521 (MPU-6050) sensor ntsuas lub kaum ntse ntse. Peb yuav tsum txuas MPU-6050 mus rau Arduino UNO zoo li pom hauv daim duab. Yog li,

  • VCC rau 5V (MPU-6050 ua haujlwm nrog 3.3V tab sis GY-521 nce nws mus rau 5V.),
  • NCO to GND,
  • SCL rau A5,
  • SDA to A4,
  • AWM to GND,
  • INT rau tus lej digital 2.

Kauj ruam 2: Code

Code
Code

Nov yog cov cai. Nws siv I2C. Kuv coj qee qhov chaws ntawm internet. (I2C ib feem)

// Sau los ntawm Ahmet Burkay KIRNIK // Ntsuas Ntawm Lub Ntsej Muag nrog MPU-6050 (GY-521)

#suav nrog

ua int MPU_addr = 0x68; int16_t AcX, AcY, AcZ, Tmp, GyX, GyY, GyZ;

int minVal = 265; int maxVal = 402;

ob x; y. ob y; xo. ob z; ua.

teeb tsa tsis muaj dabtsis () {Wire.begin (); Wire.beginTransmission (MPU_addr); Hlau.write (0x6B); Hlau.write (0); Wire.endTransmission (muaj tseeb); Serial.begin (9600); } void loop () {Wire.beginTransmission (MPU_addr); Hlau.write (0x3B); Wire.endTransmission (tsis tseeb); Wire.requestFrom (MPU_addr, 14, muaj tseeb); AcX = Wire.read () << 8 | Wire.read (); AcY = Wire.read () << 8 | Wire.read (); AcZ = Wire.read () << 8 | Wire.read (); int xAng = daim ntawv qhia (AcX, minVal, maxVal, -90, 90); int yAng = daim ntawv qhia (AcY, minVal, maxVal, -90, 90); int zAng = daim ntawv qhia (AcZ, minVal, maxVal, -90, 90);

x = RAD_TO_DEG * (atan2 (-yAng, -zAng)+PI); y = RAD_TO_DEG * (atan2 (-xAng, -zAng)+PI); z = RAD_TO_DEG * (atan2 (-yAng, -xAng)+PI);

Serial.print ("AngleX ="); Serial.println (x);

Serial.print ("AngleY ="); Serial.println (y);

Serial.print ("AngleZ ="); Serial.println (z); Serial.println ("-----------------------------------------"); ncua (400); }

Kauj ruam 3: Ua tiav

Ua tiav!
Ua tiav!

Nws ua tiav! Yog tias nws tsis ua haujlwm lossis koj xav tau kev pab, thov tawm lus lossis xa email. Koj tuaj yeem pom kuv tus email chaw nyob los ntawm cov lus pom. Los ntawm txoj kev, Kuv Lus Askiv tsis zoo yog li kuv thov zam txim rau kuv cov lus Askiv tsis zoo.

Ahmet Burkay KIRNIK

Istanbul/TURKEY

Kho: Tom qab 2 xyoos, kuv cov lus Askiv tau zoo dua yog li kuv kho qee qhov yuam kev.

Pom zoo: