残疾人手势控制轮椅
借助与加速度计传感器相对应的手势,轮椅将移动
项目介绍
$ https://drive.google.com/open?id=1RNI2ehaknWPN0lPpKm8wv95DUVcTr8H6$
•印度农村和城市地区的残疾人比例都有所增加。残疾可能是由于出生或由于某种医疗或意外原因造成的。
•该项目的目的是制作一个手势控制轮椅,并使用加速度计作为传感器,帮助身体残疾的人从一个地方移动到另一个地方,只需用手指示
•今天在印度,许多人患有残疾,有些人的下半身瘫痪了。这款轮椅将增加舒适度,使人们的生活更轻松
接收机代码
#include <nRF24L01.h>
#include <printf.h>
#include <RF24.h>
#include <RF24_config.h>
#include <SPI.h> //SPI library for communicate with the nRF24L01+
#include "RF24.h" //The main library of the nRF24L01+
const int enbA = 3;
const int enbB = 5;
const int IN1 = 2; //Right Motor (-)
const int IN2 = 4; //Right Motor (+)
const int IN3 = 7; //Left Motor (+)
const int IN4 = 6; //Right Motor (-)
int RightSpd = 130;
int LeftSpd = 130;
int data[2];
RF24 radio(9,10);
const uint64_t pipe = 0xE8E8F0F0E1LL;
void setup(){
//Define the motor pins as OUTPUT
pinMode(enbA, OUTPUT);
pinMode(enbB, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
Serial.begin(9600);
radio.begin();
radio.openReadingPipe(1, pipe);
radio.startListening();
}
void loop(){
if (radio.available()){
radio.read(data, sizeof(data));
if(data[0] > 380){
//forward
analogWrite(enbA, RightSpd);
analogWrite(enbB, LeftSpd);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
if(data[0] < 310){
//backward
analogWrite(enbA, RightSpd);
analogWrite(enbB, LeftSpd);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
if(data[1] > 180){
//left
analogWrite(enbA, RightSpd);
analogWrite(enbB, LeftSpd);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
}
if(data[1] < 110){
//right
analogWrite(enbA, RightSpd);
analogWrite(enbB, LeftSpd);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
if(data[0] > 330 && data[0] < 360 && data[1] > 130 && data[1] < 160){
//stop car
analogWrite(enbA, 0);
analogWrite(enbB, 0);
}
}
}
发射机代码
#include <SPI.h> //SPI library for communicate with the nRF24L01+
#include "RF24.h" //The main library of the nRF24L01+
#include "Wire.h" //For communicate
#include "I2Cdev.h" //For communicate with MPU6050
#include "MPU6050.h" //The main library of the MPU6050
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(void){
Serial.begin(9600);
Wire.begin();
mpu.initialize(); //Initialize the MPU object
radio.begin(); //Start the nRF24 communicate
radio.openWritingPipe(pipe); //Sets the address of the receiver to which the program will send data.
}
void loop(void){
mpu.getMotion6(&ax, &ay, &az, &gx, &gy, &gz);
data[0] = map(ax, -17000, 17000, 300, 400 ); //Send X axis data
data[1] = map(ay, -17000, 17000, 100, 200); //Send Y axis data
radio.write(data, sizeof(data));
}