Monil Patel
Published © GPL3+

Gesture Controlled Wheelchair

Wheelchair whose motion can be controlled using simple hand gestures.

BeginnerShowcase (no instructions)24 hours4,821
Gesture Controlled Wheelchair

Things used in this project

Story

Read more

Code

Code for wheel chair(Arduino uno)

C/C++
upload this code to your arduino uno
connect the motors and NRF module
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
RF24 radio(9, 10); // CE, CSN
const byte address[6] = "00001";
void setup() {
 pinMode(6,OUTPUT);
 pinMode(7,OUTPUT);
 pinMode(5,OUTPUT);
 pinMode(4,OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(0, address);   //Setting the address at which we will receive the data
radio.setPALevel(RF24_PA_MIN);       //You can set this as minimum or maximum depending on the distance between the transmitter and receiver.
radio.startListening();              //This sets the module as receiver
}
void loop()
{

char text = "";                 //Saving the incoming data
radio.read(&text, sizeof(text));    //Reading the data
Serial.println(text);
   switch(text)
    {
    case 'F':  
      forward();
      break;
    case 'B':  
      back();
      break; 
    case 'L':  
      left();
      break;
    case 'R':
      right();
      break;
    case 'S':
      Stop();
      break;
  /*  case 'O':  
      Fleft();
      break;
    case 'N':
      Fright();
      break;
    case 'P':  
      Bleft();
      break;
    case 'M':
      Bright();
      break;
          */
    
    }


delay(20);



}


void forward()
{
 
  digitalWrite(6,HIGH);
  digitalWrite(7,LOW);
  
  
 
}
void back()
{
  digitalWrite(6,LOW);
  digitalWrite(7,HIGH); 

}


void left()
{
  digitalWrite(4,LOW);
  digitalWrite(5,HIGH); 
}
void right()
{
  digitalWrite(5,LOW);
  digitalWrite(4,HIGH);

  
}
void Stop()
{
  digitalWrite(6,LOW);
  digitalWrite(7,LOW);
  digitalWrite(4,LOW);
  digitalWrite(5,LOW);
}
/*
void Fright()
{
  right();
  forward();
  
}
void Fleft()
{
  left();
  forward();
}

void Bleft()
{
  left();
  back();
}
void Bright()
{
  right();
  back();
}
*/

Code for golve (Arduino nano)

C/C++
upload this code to your nano and connect MPU and NRF modules
#include <GY6050.h>
#include <Wire.h>
#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>

RF24 radio(7, 8); // CE, CSN
const byte address[6] = "00001";
             
 
int X=0;
int Y=0;
GY6050 gyro(0x68);

void setup()
{
 
  Serial.begin(9600);
  radio.begin();
  radio.openWritingPipe(address);
  radio.setPALevel(RF24_PA_MIN);
  radio.stopListening();

  Serial.begin(9600);
  Wire.begin();
  gyro.initialisation();
  delay(2500);
}

void loop() 
{

   X= gyro.refresh('A', 'X');
   Y= gyro.refresh('A', 'Y');
   
   if(X>-10 && X<10 && Y>-10 && Y<10)
    {
     
      const char text[] = "S";
      radio.write(&text, sizeof(text)); 
    
    }
   
   if(X<-50 && Y>-10 && Y<10)
    {  
        const char text[] = "F";
      radio.write(&text, sizeof(text)); 
    }
    
    if(X>50 && Y>-10 && Y<10)
    {
         const char text[] = "B";
      radio.write(&text, sizeof(text)); 
    }
    
    if(Y<-50 && X>-10 && X<10)
    {
          const char text[] = "R";
      radio.write(&text, sizeof(text)); 
    }
    if(Y>50 && X>-10 && X<10)
    {
        const char text[] = "L";
      radio.write(&text, sizeof(text)); 
    }  
    if(Y<-50 && X<-30)
    {
         const char text[] = "N";
      radio.write(&text, sizeof(text));  //right+forward
    }
      
      if(Y<-50 && X>30)
    {
       const char text[] = "M";
      radio.write(&text, sizeof(text));   //R+B
    }
  
      if(Y>50 && X<-30)
    {
     const char text[] = "O";
      radio.write(&text, sizeof(text)); ;    //L+F
    }
      if(Y>50 && X>40)
    {
      const char text[] = "P";
      radio.write(&text, sizeof(text));     //L+B
    }
  
  }
 

Credits

Monil Patel

Monil Patel

2 projects • 8 followers

Comments