Gesture Controlled Door Using Servo Motor
by RameshDofbot in Circuits > Arduino
703 Views, 1 Favorites, 0 Comments
Gesture Controlled Door Using Servo Motor
Here to Control the Car doors using APDS-9960 Gesture sensor using servo and send data to Android application through Bluetooth HC-0 5 for graphic image on door opening/closing.
Components required:
Arduino uno: 1 no
APDS-9960 - 1 no
Servo SG90 OR MG995- 3 nos
Bluetooth HC-05- 1 no
LCD 20X4, I2c- 1no
APDS-9960:
This is the SparkFun RGB and Gesture Sensor, a small breakout board with a built in APDS-9960 sensor that offers ambient light and color measuring, proximity detection, and touchless gesture sensing. With this RGB and Gesture Sensor you will be able to control a computer, microcontroller, robot, and more with a simple swipe of your hand! This is, in fact, the same sensor that the Samsung Galaxy S5 uses and is probably one of the best gesture sensors on the market for the price. The APDS-9960 is a serious little piece of hardware with built in UV and IR blocking filters, four separate diodes sensitive to different directions, and an I2C compatible interface. For your convenience we have broken out the following pins:
VL (optional power to IR LED),
GND (Ground),
VCC (power to APDS-9960 sensor),
SDA (I2C data),
SCL (I2C clock), and INT (interrupt).
Each APDS-9960 also has a detection range of 4 to 8 inches (10 to 20 cm).
Servo motor:
A servo motor is an electric device used for precise control of angular rotation. It is used in applications that demand precise control over motion, like in case of control of a robotic arm. The rotation angle of the servo motor is controlled by applying a PWM signal to it. By varying the width of the PWM signal, we can change the rotation angle and direction of the motor. Wire Configuration: Brown - Ground wire connected to the ground of system Red - Powers the motor typically +5V is used Orange - PWM signal is given in through this wire to drive the motor
Bluetooth HC-05:
HC-05 is a Bluetooth module which is designed for wireless comunication. This module can be used in a master or slave configuration. Bluetooth serial modules allow all serial enabled devices to communicate with each other using Bluetooth. It has 6 pins, 1. Key/EN: It is used to bring Bluetooth module in AT commands mode. If Key/EN pin is set to high, then this module will work in command mode. Otherwise by default it is in data mode. The default baud rate of HC-05 in command mode is 38400bps and 9600 in data mode. HC-05 module has two modes,
1. Data mode: Exchange of data between devices.
2. Command mode: It uses AT commands which are used to change setting of HC-05. To send these commands to module serial (USART) port is used. 2. VCC: Connect 5 V or 3.3 V to this Pin.
3. GND: Ground Pin of module.
4. TXD: Transmit Serial data (wirelessly received data by Bluetooth module transmitted out serially on TXD pin) 5. RXD: Receive data serially (received data will be transmitted wirelessly by Bluetooth module).
6. State: It tells whether module is connected or not. HC-05 module Information HC-05 has red LED which indicates connection status, whether the Bluetooth is connected or not. Before connecting to HC-05 module this red LED blinks continuously in a periodic manner. When it gets connected to any other Bluetooth device, its blinking slows down to two seconds.
This module works on 3.3 V. We can connect 5V supply voltage as well since the module has on board 5 to 3.3 V regulator. As HC-05 Bluetooth module has 3.3 V level for RX/TX and microcontroller can detect 3.3 V level, so, no need to shift transmit level of HC-05 module. But we need to shift the transmit voltage level from microcontroller to RX of HC-05 module.
HC-05 Default Settings
Default Bluetooth Name: “HC-05”
Default Password: 1234 or 0000
Default Communication: Slave
Default Mode: Data Mode Data Mode
Baud Rate: 9600, 8, N, 1
Command Mode Baud Rate: 38400, 8, N, 1
Default firmware: LINVOR
Arduino Code:
#include
// Pins
#define APDS9960_INT 2 // Needs to be an interrupt pin
// Constants
// Global Variables
SparkFun_APDS9960 apds = SparkFun_APDS9960();
int isr_flag = 0;
#include Servo
RoofSERVO1; // create servo object to control a servo
Servo SideSERVO2; // create servo object to control a servo
Servo RearSERVO3; // create servo object to control a servo // twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo
#include LiquidCrystal_I2C lcd(0x27,20,4);
void setup() {
// Set interrupt pin as input
pinMode(APDS9960_INT, INPUT);
// Initialize Serial port
Serial.begin(9600);
Serial.println();
Serial.println(F("--------------------------------"));
Serial.println(F("SparkFun APDS-9960 - GestureTest"));
Serial.println(F("--------------------------------")); // Initialize interrupt service routine
attachInterrupt(0, interruptRoutine, FALLING);
// Initialize APDS-9960 (configure I2C and initial values)
if ( apds.init() ) {
Serial.println(F("APDS-9960 initialization complete")); }
else {
Serial.println(F("Something went wrong during APDS-9960 init!")); } // Start running the APDS-9960 gesture sensor engine
if ( apds.enableGestureSensor(true) ) {
Serial.println(F("Gesture sensor is now running")); }
else {
Serial.println(F("Something went wrong during gesture sensor init!"));
}
RoofSERVO1.attach(9);
SideSERVO2.attach(10);
RearSERVO3.attach(11);
lcd.init(); // initialize the lcd // Print a message to the LCD.
lcd.backlight();
lcd.setCursor(0,0);
lcd.print(" GESTURE CONTROLLED ");
lcd.setCursor(0,1);
lcd.print("DOOR OPENING & CLOSE");
lcd.setCursor(0,2);
lcd.print("USING SERVO MOTOR , ");
lcd.setCursor(0,3);
lcd.print("BLUETOOTH & ANDROID ");
delay (3000);
lcd.clear(); }
void loop() { lcd.backlight();
lcd.setCursor(0,0);
lcd.print("GESTURE DOOR CONTROL");
if( isr_flag == 1 ) { detachInterrupt(0);
handleGesture();
isr_flag = 0;
attachInterrupt(0, interruptRoutine, FALLING); } }
void interruptRoutine() { isr_flag = 1; }
void handleGesture() {
if ( apds.isGestureAvailable() ) { switch ( apds.readGesture() ) {
case DIR_UP:
Serial.println("10"); //
for(pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree RoofSERVO1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
lcd.setCursor(0,1);
lcd.print("S1: TOP ROOF OPENED "); //
break;
case DIR_DOWN:
Serial.println("20"); //
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
RoofSERVO1.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
lcd.setCursor(0,1);
lcd.print("S1: TOP ROOF CLOSED "); //
break;
case DIR_LEFT:
Serial.println("30"); //
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree SideSERVO2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
lcd.setCursor(0,2);
lcd.print("S2: SIDE DOOR CLOSED"); //
break;
case DIR_RIGHT:
Serial.println("40"); //
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
SideSERVO2.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
lcd.setCursor(0,2);
lcd.print("S2: SIDE DOOR OPENED"); //
break;
case DIR_NEAR:
Serial.println("50"); // for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree
RearSERVO3.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
lcd.setCursor(0,3); lcd.print("S3: REAR DOOR CLOSED"); //
break;
case DIR_FAR:
Serial.println("60"); // for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees RearSERVO3.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position }
lcd.setCursor(0,3);
lcd.print("S3: REAR DOOR OPENED"); //
break;
default: Serial.println("100"); } } }
https://www.dofbot.com/post/gesture-controlled-doo...