Yasmeen RoumieJames Chin
Published © GPL3+

Hand Controlled Delorean

Use your hand, which is inside the glove, to move the car, which is connected by bluetooth.

IntermediateWork in progress760
Hand Controlled Delorean

Things used in this project

Hardware components

Glove
×1
Wheel
×4
DC motor (generic)
×2
Teensy
×1
Cardboard Box
×1
Lego
×10
9V battery (generic)
9V battery (generic)
×2
3D Printed Motor Mount
×2
Accelerometer Module (Grove kit)
×1

Code

Car Driver

C/C++
Actually moves the car based on the given accelerometer numbers.
#include <Servo.h>

char blueToothVal;
char lastValue;
Servo servo;
int val;
int motorPin = 8;

void setup() {
  // put your setup code here, to run once:
  Serial1.begin(9600);
  servo.attach(6);
  servo.write(90); 
  pinMode(motorPin, OUTPUT);
  lastValue = 0;
}

void loop() {
  // put your main code here, to run repeatedly:
  if (Serial1.available()) {
    blueToothVal = Serial1.read();
  }
  if (blueToothVal != lastValue) {
    if (blueToothVal == '0') {
      servo.write(90); 
      delay(abs(lastValue - blueToothVal)*15);
      lastValue = blueToothVal;
    }
    if (blueToothVal == '1') {
      servo.write(105);
      delay(abs(lastValue - blueToothVal)*15);
      lastValue = blueToothVal;
    }
    if (blueToothVal == '2') {
      servo.write(75);
      delay(abs(lastValue - blueToothVal)*15);
      lastValue = blueToothVal;
    }
    if (blueToothVal == '3') {
      digitalWrite(motorPin, HIGH);  
    }
    if (blueToothVal == '4') {
      digitalWrite(motorPin, LOW); 
    }
  }
 /* else {
    digitalWrite(motorPin, LOW); 
  }*/
}

Accelerometer

C/C++
Finds out which way your hand moves and tells which way the car should move.
int count = 0;

char x = '0';
char y = '0';

void setup() {
  Serial.begin(9600);
  delay(1000);
}

void loop() {
  // Your computer will receive these characters from a USB keyboard.


  if (analogRead(A0) > 580) {
    x = '4';
  }
  else if (analogRead(A0) < 500) {
    x = '3';
  }
  
  
  if (analogRead(A1) > 580) { //right
    y = '2';
  }
  else if (analogRead(A1) < 470) { //left
    y = '1';
  }
  else {
    y = '0';  
  }
  
  
  //Keyboard.println(x);
  
  Keyboard.println(y);

  //Keyboard.println(count);

  // increment the count
  count = count + 1;

  // typing too rapidly can overwhelm a PC
  delay(25);
}

Credits

Yasmeen Roumie

Yasmeen Roumie

1 project • 3 followers
James Chin

James Chin

1 project • 4 followers
Thanks to My mom.

Comments