Hackster is hosting Hackster Holidays, Finale: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Tuesday!Stream Hackster Holidays, Finale on Tuesday!
Maker 101
Published © GPL3+

The Flexible Sensor Hand Controller

The Flexible Sensor Hand Controller makes it possible to control your projects with your finger movements via wireless communication.

IntermediateShowcase (no instructions)3 hours1,454
The Flexible Sensor Hand Controller

Things used in this project

Hardware components

Adafruit Long Flex sensor
×5
Arduino Nano V3
×1
NRF24L01 Transceiver
×1
10uF Capacitor
×1
10K Resistor
×1
Header Male
×1
Header Female
×1
Power Jack 5.5MM
×1
On/Off Switch
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering Iron Kit

Story

Read more

Schematics

Flex Sensor Transmitter Breadboard Circuit

Code

Transmitter - Flex Sensor Controller

Arduino
#include <SPI.h>                      //the communication interface with the modem
#include "RF24.h"                     //the library which helps us to control the radio modem

//define the data pins
int flexPin2 = A2;
int flexPin3 = A3;
int flexPin4 = A4;

//define variable values
int flexVal2;
int flexVal3;
int flexVal4;

int data[3];

RF24 radio(10,9);                     //10 and 9 are a digital pin numbers to which signals CE and CSN are connected.
                                      
const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem, that will receive data from Arduino.


void setup(void){
  Serial.begin(9600);
  radio.begin();                      //it activates the modem.
  radio.openWritingPipe(pipe);        //sets the address of the receiver to which the program will send data.
}

void loop(){
  //Send signal data
  flexVal2 = analogRead(flexPin2);
  flexVal3 = analogRead(flexPin3);
  flexVal4 = analogRead(flexPin4);
  
  data[0] = flexVal2;
  data[1] = flexVal3;
  data[2] = flexVal4;
  
  radio.write(data, sizeof(data));
  
}

Receiver - Motor Control

Arduino
#include <SPI.h>      //the communication interface with the modem
#include "RF24.h"     //the library which helps us to control the radio modem (nRF24L)

//Motor A
const int RightMotorForward = 3;    // IN1
const int RightMotorBackward = 2;   // IN2
//Motor B
const int LeftMotorForward = 5;     // IN3
const int LeftMotorBackward = 4;    // IN4


RF24 radio(10,9);     /*This object represents a modem connected to the Arduino. 
                      Arguments 10 and 9 are a digital pin numbers to which signals 
                      CE and CSN are connected.*/

const uint64_t pipe = 0xE8E8F0F0E1LL; //the address of the modem,that will receive data from the Arduino.

int data[3];


void setup(){
  Serial.begin(9600);
  pinMode(RightMotorForward, OUTPUT);
  pinMode(LeftMotorForward, OUTPUT);
  pinMode(LeftMotorBackward, OUTPUT);
  pinMode(RightMotorBackward, OUTPUT);
  
  radio.begin();                    //it activates the modem.
  radio.openReadingPipe(1, pipe);   //determines the address of our modem which receive data.
  radio.startListening();           //enable receiving data via modem
  }

void loop(){
  if(radio.available()){
    radio.read(data, sizeof(data));
    
    
    if(data[0] > 750){
    digitalWrite(RightMotorForward, HIGH);
    digitalWrite(RightMotorBackward, LOW);
    digitalWrite(LeftMotorForward, HIGH);
    digitalWrite(LeftMotorBackward, LOW);
    Serial.println("FORWARD");
    }

    if(data[1] > 750){
    digitalWrite(RightMotorForward, LOW);
    digitalWrite(RightMotorBackward, HIGH);
    digitalWrite(LeftMotorForward, LOW);
    digitalWrite(LeftMotorBackward, HIGH);
    Serial.println("BACKWARD");
    }
    
    if(data[2] > 750 ){
    digitalWrite(RightMotorForward, LOW);
    digitalWrite(RightMotorBackward, HIGH);
    digitalWrite(LeftMotorForward, HIGH);
    digitalWrite(LeftMotorBackward, LOW);
    Serial.println("TURN");
    }

    if(data[0] < 750 && data[1] < 750 && data[2] < 750 ){
    digitalWrite(RightMotorForward, LOW);
    digitalWrite(RightMotorBackward, LOW);
    digitalWrite(LeftMotorForward, LOW);
    digitalWrite(LeftMotorBackward, LOW);
    Serial.println("STOP");
    }

  }
}

Credits

Maker 101
51 projects • 179 followers
Maker 101; Beginner and intermediate level Maker projects!

Comments