Devices & Components
Arduino Nano
nRF24 Module (Generic)
DC Motor, 12 V
Jumper wires (generic)
Dual H-Bridge motor drivers L298
Hardware & Tools
Soldering iron (generic)
Hot glue gun (generic)
Software & Tools
Arduino IDE
Project description
Code
Receiver Code
arduino
1#include <nRF24L01.h> 2#include <printf.h> 3#include <RF24.h> 4#include <RF24_config.h> 5#include <SPI.h> //SPI library for communicate with the nRF24L01+ 6#include "RF24.h" //The main library of the nRF24L01+ 7 8 9const int enbA = 3; 10const int enbB = 5; 11 12const int IN1 = 2; //Right Motor (-) 13const int IN2 = 4; //Right Motor (+) 14const int IN3 = 7; //Left Motor (+) 15const int IN4 = 6; //Right Motor (-) 16 17int RightSpd = 130; 18int LeftSpd = 130; 19 20int data[2]; 21 22 23RF24 radio(9,10); 24 25const uint64_t pipe = 0xE8E8F0F0E1LL; 26 27void setup(){ 28 //Define the motor pins as OUTPUT 29 pinMode(enbA, OUTPUT); 30 pinMode(enbB, OUTPUT); 31 pinMode(IN1, OUTPUT); 32 pinMode(IN2, OUTPUT); 33 pinMode(IN3, OUTPUT); 34 pinMode(IN4, OUTPUT); 35 36 Serial.begin(9600); 37 radio.begin(); 38 radio.openReadingPipe(1, pipe); 39 radio.startListening(); 40 } 41 42void loop(){ 43 if (radio.available()){ 44 radio.read(data, sizeof(data)); 45 46 if(data[0] > 380){ 47 //forward 48 analogWrite(enbA, RightSpd); 49 analogWrite(enbB, LeftSpd); 50 digitalWrite(IN1, HIGH); 51 digitalWrite(IN2, LOW); 52 digitalWrite(IN3, HIGH); 53 digitalWrite(IN4, LOW); 54 } 55 56 if(data[0] < 310){ 57 //backward 58 analogWrite(enbA, RightSpd); 59 analogWrite(enbB, LeftSpd); 60 digitalWrite(IN1, LOW); 61 digitalWrite(IN2, HIGH); 62 digitalWrite(IN3, LOW); 63 digitalWrite(IN4, HIGH); 64 } 65 66 if(data[1] > 180){ 67 //left 68 analogWrite(enbA, RightSpd); 69 analogWrite(enbB, LeftSpd); 70 digitalWrite(IN1, HIGH); 71 digitalWrite(IN2, LOW); 72 digitalWrite(IN3, LOW); 73 digitalWrite(IN4, HIGH); 74 } 75 76 if(data[1] < 110){ 77 //right 78 analogWrite(enbA, RightSpd); 79 analogWrite(enbB, LeftSpd); 80 digitalWrite(IN1, LOW); 81 digitalWrite(IN2, HIGH); 82 digitalWrite(IN3, HIGH); 83 digitalWrite(IN4, LOW); 84 } 85 86 if(data[0] > 330 && data[0] < 360 && data[1] > 130 && data[1] < 160){ 87 //stop car 88 analogWrite(enbA, 0); 89 analogWrite(enbB, 0); 90 } 91 } 92}
Receiver Code
arduino
1#include <nRF24L01.h> 2#include <printf.h> 3#include <RF24.h> 4#include <RF24_config.h> 5#include <SPI.h> //SPI library for communicate with the nRF24L01+ 6#include "RF24.h" //The main library of the nRF24L01+ 7 8 9const int enbA = 3; 10const int enbB = 5; 11 12const int IN1 = 2; //Right Motor (-) 13const int IN2 = 4; //Right Motor (+) 14const int IN3 = 7; //Left Motor (+) 15const int IN4 = 6; //Right Motor (-) 16 17int RightSpd = 130; 18int LeftSpd = 130; 19 20int data[2]; 21 22 23RF24 radio(9,10); 24 25const uint64_t pipe = 0xE8E8F0F0E1LL; 26 27void setup(){ 28 //Define the motor pins as OUTPUT 29 pinMode(enbA, OUTPUT); 30 pinMode(enbB, OUTPUT); 31 pinMode(IN1, OUTPUT); 32 pinMode(IN2, OUTPUT); 33 pinMode(IN3, OUTPUT); 34 pinMode(IN4, OUTPUT); 35 36 Serial.begin(9600); 37 radio.begin(); 38 radio.openReadingPipe(1, pipe); 39 radio.startListening(); 40 } 41 42void loop(){ 43 if (radio.available()){ 44 radio.read(data, sizeof(data)); 45 46 if(data[0] > 380){ 47 //forward 48 analogWrite(enbA, RightSpd); 49 analogWrite(enbB, LeftSpd); 50 digitalWrite(IN1, HIGH); 51 digitalWrite(IN2, LOW); 52 digitalWrite(IN3, HIGH); 53 digitalWrite(IN4, LOW); 54 } 55 56 if(data[0] < 310){ 57 //backward 58 analogWrite(enbA, RightSpd); 59 analogWrite(enbB, LeftSpd); 60 digitalWrite(IN1, LOW); 61 digitalWrite(IN2, HIGH); 62 digitalWrite(IN3, LOW); 63 digitalWrite(IN4, HIGH); 64 } 65 66 if(data[1] > 180){ 67 //left 68 analogWrite(enbA, RightSpd); 69 analogWrite(enbB, LeftSpd); 70 digitalWrite(IN1, HIGH); 71 digitalWrite(IN2, LOW); 72 digitalWrite(IN3, LOW); 73 digitalWrite(IN4, HIGH); 74 } 75 76 if(data[1] < 110){ 77 //right 78 analogWrite(enbA, RightSpd); 79 analogWrite(enbB, LeftSpd); 80 digitalWrite(IN1, LOW); 81 digitalWrite(IN2, HIGH); 82 digitalWrite(IN3, HIGH); 83 digitalWrite(IN4, LOW); 84 } 85 86 if(data[0] > 330 && data[0] < 360 && data[1] > 130 && data[1] < 160){ 87 //stop car 88 analogWrite(enbA, 0); 89 analogWrite(enbB, 0); 90 } 91 } 92}
Transmitter code
arduino
1#include <SPI.h> //SPI library for communicate with the nRF24L01+ 2#include "RF24.h" //The main library of the nRF24L01+ 3#include "Wire.h" //For communicate 4#include "I2Cdev.h" //For communicate with MPU6050 5#include "MPU6050.h" //The main library of the MPU6050 6 7MPU6050 mpu; 8int16_t ax, ay, az; 9int16_t gx, gy, gz; 10int data[2]; 11 12RF24 radio(9,10); 13 14const uint64_t pipe = 0xE8E8F0F0E1LL; 15 16void setup(void){ 17 Serial.begin(9600); 18 Wire.begin(); 19 mpu.initialize(); //Initialize the MPU object 20 radio.begin(); //Start the nRF24 communicate 21 radio.openWritingPipe(pipe); //Sets the address of the receiver to which the program will send data. 22} 23 24void loop(void){ 25 26 mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz); 27 28 29 data[0] = map(ax, -17000, 17000, 300, 400 ); //Send X axis data 30 data[1] = map(ay, -17000, 17000, 100, 200); //Send Y axis data 31 radio.write(data, sizeof(data)); 32}
Downloadable files
Circuit diagram of wheel chair RECEIVER
Circuit diagram of wheel chair RECEIVER

wheel chair
wheel chair

Circuit diagram of hand gesture TRANSMITTER
Circuit diagram of hand gesture TRANSMITTER

Circuit diagram of wheel chair RECEIVER
Circuit diagram of wheel chair RECEIVER

wheel chair
wheel chair

Circuit diagram of hand gesture TRANSMITTER
Circuit diagram of hand gesture TRANSMITTER

Comments
Only logged in users can leave comments