Posts

Showing posts from December, 2019

DC motor controlled by Gyro MPU 6050 using Arduino & L298N Motor driver - Wireless Connection

Image
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

DC motor controlled by Gyro MPU 6050 using Arduino & L298N Motor driver - Wired Connection

Image
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 Program Code: #include <Wire.h> #include <MPU6050.h> #define motor1_pin1 5 //PWM - Digital Pins #define motor1_pin2 6 //PWM - Digital Pins #define motor2_pin1 9 //PWM - Digital Pins #define motor2_pin2 10 //PWM - Digital Pins MPU6050 gy_521; int16_t ax, ay, az; int16_t gx, gy, gz; int motor1_speed1; int motor2_speed1; int motor1_speed2; int motor2_speed2; void setup ( ){ Wire.begin( ); Serial.begin (9600); Serial.println ("Initializing MPU and testing connections"); gy_521.initialize ( ); Serial.println(gy_521.testConnection( ) ? "Successfully Connected" : "Connection failed"); delay(1000); Serial.println("Reading Values"); delay(1000); } void loop ( ){ gy_521.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); ax = map(ax, -17000, 1

DC motor controlled by Joystick using Arduino & L298N Motor driver - Wireless Connection

Image
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos DC Motor - 2 Nos L298N Motor Driver - 1 Nos Joystick - 1 Nos Transceiver - 2 Nos Program Code: Transmitter Code: #include <SPI.h> #include "RF24.h" int x_axis = A1; int y_axis = A2; int xvalue; int yvalue; int data[2]; RF24 radio(9,10); const uint64_t pipe=0xE8E8F0F0E1LL; void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(pipe); } void loop() {{ xvalue=analogRead(x_axis); xvalue=map(xvalue,0,1023,0,127); data[0]=xvalue; radio.write(data,1); } { yvalue=analogRead(y_axis); yvalue=map(yvalue,0,1023,128,255); data[0]=yvalue; radio.write(data,1); } Serial.println(xvalue); Serial.println(yvalue); } Receiver Code: #include <SPI.h> #include "RF24.h" const int motorforward = A1; const int motorbackward = A2; const int motorleft = A3; const int motorright = A4; int data[2]; RF24 radio(9,10); // CE,CS

DC motor controlled by Joystick using Arduino & L298N Motor driver - Wired Connection

Image
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos DC Motor - 2 Nos L298N Motor Driver - 1 Nos Joystick - 1 Nos Program Code: int joystrick1 = A1; int joystrick2 = A2; int val1; int val2; void setup() {   // put your setup code here, to run once: Serial.begin(9600); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(A1, INPUT); pinMode(A2, INPUT); } void loop() {   // put your main code here, to run repeatedly: int val1 = analogRead(joystrick1); int val2 = analogRead(joystrick2); if(val1 > 1 && val1 < 490){ val1 = map(val1, 1, 490, 255, 0); analogWrite(6,val1); analogWrite(5,0); } if(val1 > 530 && val1 < 1023){ val1 = map(val1, 530, 1023, 0, 255); analogWrite(5,val1); analogWrite(6,0); } if(val1 > 491 && val1 < 529){ val1 = map(val1, 491, 529, 0, 0); analogWrite(5,val1); analogWrite(6,val1); } if(val2 > 1 &&

DC motor controlled by Potentiometer using Arduino & L298N Motor driver - Wireless Connection

Image
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos DC Motor - 2 Nos L298N Motor Driver - 1 Nos Potentiometer - 2 Nos Transceiver - 2 Nos Program Code: Transmitter Code: #include <SPI.h> #include "RF24.h" int data[2]; RF24 radio(9,10); const uint64_t pipe = 0xE8E8F0F0E1LL; int potpin1=A1; int val1; int potpin2=A2; int val2; void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(pipe); } void loop() {{ val1=analogRead(potpin1); val1=map(val1,0,1023,0,127); data[0]=val1; radio.write(data,1); } { val2=analogRead(potpin2); val2=map(val2,0,1023,128,255); data[0]=val2; radio.write(data,1); } Serial.println(val1); Serial.println(val2); } Receiver Code: #include <SPI.h> #include "RF24.h" int data[2]; int forward = A1; int backward = A2; int left = A3; int right = A4; const uint64_t pipe = 0xE8E8F0F0E1LL; RF24 radio(9,10); // CE,CSN: void setup() { pi

DC motor controlled by Potentiometer using Arduino & L298N - Wired Connection

Image
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos DC Motor - 1 Nos L298N Motor Driver - 1 Nos Potentiometer - 1 Nos Program Code: int Pot = A1; int val; void setup() { Serial.begin(9600);   // put your setup code here, to run once: pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(A1, INPUT); } void loop() {   // put your main code here, to run repeatedly: int val = analogRead(Pot); if(val > 1 && val < 490){ val = map(val, 1, 490, 255, 0); analogWrite(5,0); analogWrite(6,val); } if(val > 530 && val < 1023){ val = map(val, 530, 1023, 0, 255); analogWrite(6,0); analogWrite(5,val); } if(val > 491 && val < 529){ val = map(val, 491, 529, 0, 0); analogWrite(6,0); analogWrite(5,0); } Serial.println(val); } Video:

Servomotor controlled by Potentiometer using Arduino & Tranceiver - Wire...

Image
Circuit Diagram: Required Components: Arduino uno/nano - 2 Nos Battery - 2 Nos Transceiver - 2 Nos Servo Motor - 2 Nos Potentiometer - 2 Nos Program Code: Transmitter Code: #include <SPI.h> #include "RF24.h" int msg[1]; RF24 radio(9,10); const uint64_t pipe=0xE8E8F0F0E1LL; int Potpin=A1; int val; void setup() { radio.begin(); radio.openWritingPipe(pipe); } void loop() { val=analogRead(Potpin); val=map(val,0,1023,0,179); msg[0]=val; radio.write(msg,1); } Receiver Code: #include <SPI.h> #include "RF24.h" #include <Servo.h> Servo myservo; RF24 radio(9,10); const uint64_t pipe=0xE8E8F0F0E1LL; int msg[1]; void setup() {   myservo.attach(5);   radio.begin();   radio.openReadingPipe(1,pipe);   radio.startListening(); } void loop() {   if(radio.available()){     bool done = false;     while(!done)     {       done = radio.read(msg,1);       myservo.write(msg[0]);     }   } } Video:

Servo motor controlled by Joystick using Arduino - Wired Connection

Image
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos Servo Motor - 1 Nos Joystick - 1 Nos Program Code: #include <Servo.h>   Servo servo1; Servo servo2; int joyX = A1; int joyY = A2;   int servoVal;   void setup() {   servo1.attach(6);   servo2.attach(5); }   void loop() {     servoVal = analogRead(joyX);   servoVal = map(servoVal, 0, 1023, 5, 175); // To reduce Buzz effect adjust range form (0-180) to (5-175)   servo1.write(servoVal);   servoVal = analogRead(joyY);   servoVal = map(servoVal, 0, 1023, 5, 175); // To reduce Buzz effect adjust range form (0-180) to (5-175)   servo2.write(servoVal);   delay(15); } Video:

Servo motor controlled by Joystick using Arduino & Transceiver - Wireles...

Image
Circuit Diagram: Required Components: Arduino uno/nano - 2 Nos Battery - 2 Nos Transceiver - 2 Nos Servo Motor - 2 Nos Joystick - 1 Nos Program Code: Transmitter Code: #include <SPI.h> #include "RF24.h" #include "nRF24L01.h" int potpin1 = A1; int potpin2 = A2; int data[2]; RF24 radio(9,10); const uint64_t pipe=0xE8E8F0F0E1LL; void setup() { Serial.begin(9600); radio.begin(); radio.openWritingPipe(pipe); } void loop(){ data[0] = analogRead(potpin1); data[1] = analogRead(potpin2); data[0] = map(data[0],0,1023,5,175); data[1] = map(data[1],0,1023,5,175); radio.write(data,sizeof(data));    {     Serial.println(data[0]);     Serial.println(data[1]);     } } Receiver Code: #include <SPI.h> #include "RF24.h" #include "nRF24L01.h" #include <Servo.h> Servo servo1; Servo servo2; RF24 radio(9,10); const uint64_t pipe=0xE8E8F0F0E1LL; int data[2]; void setup() {   servo1.attach(5);   servo2.attach(6);   Serial.begin(9

Servo Motor controlled by Gyro(MPU 6050) using Arduino - Wired Connection

Image
Circuit Diagram: Required Components: Arduino uno/nano - 1 Nos Battery - 1 Nos Servo Motor - 1 Nos Gyro (MPU 6050) - 1 Nos   Program Code: #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; Servo servo2; int val1; int val2; int prevVal1; int prevVal2; void setup() { Wire.begin(); Serial.begin(115200); Serial.println("Initialize MPU"); mpu.initialize(); Serial.println(mpu.testConnection() ? "Connected" : "Connection failed"); servo1.attach(5);  servo2.attach(6); } void loop() { mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); val1 = map(ax, -17000, 17000, 0, 179); if (val1 != prevVal1) { servo1.write(val1); prevVal1 = val1; } val2 = map(ay, -17000, 17000, 0, 179); if (val2 != prevVal2) { servo2.write(val2); prevVal2 = val2; } delay(5); } V

Servomotor controlled by Gyro(MPU6050) using Arduino & Transceiver - Wir...

Image
Circuit Diagram: Required Components: Arduino uno/nano - 2 Nos Battery - 2 Nos Transceiver - 2 Nos Servo Motor - 2 Nos Gyro (MPU6050) - 1 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); const uint64_t pipe = 0xE8E8F0F0E1LL; void setup(){ Wire.begin(); mpu.initialize(); Serial.begin(9600); radio.begin(); radio.openWritingPipe(pipe); } void loop(){ mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); data[0] = map(ax, 10, 17000, 2,178); data[1] = map(ay, 10, 17000, 2,178); radio.write(data,sizeof(data));    {     Serial.println(data[0]);     Serial.println(data[1]);     }   } Receiver Code:  #include <Servo.h> #include <SPI.h> #include "RF24.h" Servo Servo_motor_x,Servo_motor_y; RF24 radio(9,10); const