Rocket Parachute Deployment Mechanism with MPU-6050 (Arduino)
Components:
-Arduino Nano or Mini
- Gyroscope MPU 6050
-Servomotor
-Cables
-A battery of 3.7 or more volts (up to 20v)
Connections:
MPU6050:
SCL - A5
SDA - A4
INT - 2
Servo - 9
-Arduino Nano or Mini
- Gyroscope MPU 6050
-Servomotor
-Cables
-A battery of 3.7 or more volts (up to 20v)
Connections:
MPU6050:
SCL - A5
SDA - A4
INT - 2
Servo - 9
Code:
Before uploading the code to the Arduino board, you need to load the i2cdev.zip and MPU6050.zip files into the Arduino IDE library. This can be done by extracting the files inside the .zip folders and copying them into the library folder of the Arduino IDE.
i2cdev.zip: https://drive.google.com/open?id=1m311tlTBeYpiAnRucSCSWw7gB2rn-yiR
Before uploading the code to the Arduino board, you need to load the i2cdev.zip and MPU6050.zip files into the Arduino IDE library. This can be done by extracting the files inside the .zip folders and copying them into the library folder of the Arduino IDE.
i2cdev.zip: https://drive.google.com/open?id=1m311tlTBeYpiAnRucSCSWw7gB2rn-yiR
MPU6050.zip: https://drive.google.com/open?id=1GJVezngsDsghCG9yK4mBnwTB7E7yBxkQ
#include "Wire.h"
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Servo.h"
MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;
Servo servo1;
int val1;
int prevVal1;
void setup()
{
Wire.begin();
Serial.begin(38400);
Serial.println("Initialize MPU");
mpu.initialize();
Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");
servo1.attach(9);
}
void loop()
{
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
val1 = map(ax, -17000, 17000, 120, 10);
if (val1 != prevVal1)
{
servo1.write(val1);
prevVal1 = val1;
}
delay(50);
}
#include "I2Cdev.h"
#include "MPU6050.h"
#include "Servo.h"
MPU6050 mpu;
int16_t ax, ay, az;
int16_t gx, gy, gz;
Servo servo1;
int val1;
int prevVal1;
void setup()
{
Wire.begin();
Serial.begin(38400);
Serial.println("Initialize MPU");
mpu.initialize();
Serial.println(mpu.testConnection() ? "Connected" : "Connection failed");
servo1.attach(9);
}
void loop()
{
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
val1 = map(ax, -17000, 17000, 120, 10);
if (val1 != prevVal1)
{
servo1.write(val1);
prevVal1 = val1;
}
delay(50);
}
Comentarios
Publicar un comentario