DC motor controlled by Gyro MPU 6050 using Arduino & L298N Motor driver - Wireless Connection
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos DC Motor - 2 Nos L298N Motor Driver - 1 Nos Gyro MPU6050 - 1 Nos Transceiver - 2 Nos Program Code: Transmitter Code: #include <SPI.h> #include "RF24.h" #include "Wire.h" #include "I2Cdev.h" #include "MPU6050.h" MPU6050 mpu; int16_t ax, ay, az; int16_t gx, gy, gz; int data[2]; RF24 radio(9,10); uint64_t pipe = 0xE8E8F0F0E1LL; void setup(){ Serial.begin(9600); Wire.begin(); mpu.initialize(); radio.begin(); radio.openWritingPipe(pipe); } void loop(){ mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); //With this function, the acceleration and gyro values of the axis are taken. data[0] = map(ax, -17000, 17000, 0, 128); //Send X axis data data[1] = map(ay, -17000, 17000, 129, 255); //Send Y axis data rad