0% found this document useful (0 votes)
4 views10 pages

Gesture-Controlled Automation System

This document is an Arduino sketch for a multifunctional gesture glove that operates in two modes: Communication and Automation. It utilizes an LCD display to show the current mode and messages based on gestures detected from potentiometers, while also controlling a relay and a buzzer. The code includes functions to read potentiometer values, update the display, and handle gestures for both modes, providing specific messages or actions based on the detected gestures.

Uploaded by

Adwaitha MR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

Gesture-Controlled Automation System

This document is an Arduino sketch for a multifunctional gesture glove that operates in two modes: Communication and Automation. It utilizes an LCD display to show the current mode and messages based on gestures detected from potentiometers, while also controlling a relay and a buzzer. The code includes functions to read potentiometer values, update the display, and handle gestures for both modes, providing specific messages or actions based on the detected gestures.

Uploaded by

Adwaitha MR
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include <Wire.

h>

#include <LiquidCrystal_I2C.h>

const int switchPin = 13;

const int buzzerPin = 18;

const int relayPin = 5;

LiquidCrystal_I2C lcd(0x27, 16, 2); // Adjust I2C address as needed

#define MODE_COMMUNICATION 0

#define MODE_AUTOMATION 1

int currentMode = -1;

int lastSwitchState = HIGH;

String lastMessage = ""; // Store the last displayed message

bool firstDisplay = true; // Flag for the first mode display

const int potPins[] = {34, 35, 32, 33, 25}; // Pins for the 5 slide pots

int potValues[5]; // Array to store values from each pot

// Gesture thresholds

const int GESTURE_THRESHOLD = 1000; // Adjust this threshold based on your testing

void setup() {

[Link](115200);

pinMode(switchPin, INPUT_PULLUP);

pinMode(buzzerPin, OUTPUT);

pinMode(relayPin, OUTPUT);

[Link]();

[Link]();
[Link]("Multifunctional");

[Link](0, 1);

[Link]("Gesture Glove");

delay(2000);

[Link]("Choose mode:");

[Link]("Move toggle switch to left for Communication mode");

[Link]("Move toggle switch to right for Automation mode");

void loop() {

int switchState = digitalRead(switchPin);

static unsigned long lastSwitchTime = 0;

if (switchState != lastSwitchState) {

if (millis() - lastSwitchTime > 50) {

currentMode = (switchState == LOW) ?


MODE_AUTOMATION : MODE_COMMUNICATION;

firstDisplay = true; // Reset the display flag


when mode changes

updateModeDisplay();

lastSwitchState = switchState;

lastSwitchTime = millis();

if (currentMode ==
MODE_COMMUNICATION) {

readPotentiometerValues(); // Read values from the potentiometers

handleCommunicationMode();

} else if
(currentMode == MODE_AUTOMATION) {
readPotentiometerValues(); // Read values from the potentiometers

handleAutomationMode();

delay(500);

void readPotentiometerValues() {

for (int i = 0; i < 5; i++) {

potValues[i] = analogRead(potPins[i]); // Read values from each pot

void updateModeDisplay() {

static int lastMode = -1;

if (lastMode != currentMode) { // Only update LCD if the mode changes

[Link]();

[Link](0, 0);

[Link]("Mode:");
[Link](0, 1);

if (currentMode == MODE_COMMUNICATION) {

[Link]("Communication");

[Link]("Mode: Communication");

} else if (currentMode == MODE_AUTOMATION) {

[Link]("Automation");

[Link]("Mode: Automation");

lastMode = currentMode; // Update the last known mode

void handleCommunicationMode() {

if (firstDisplay) {

[Link]();

[Link](0, 0);

[Link]("Mode:");

[Link](0, 1);
[Link]("Communication");

delay(2000); // Delay to allow the user to see the mode message

firstDisplay = false; // Set the flag to false so we don't show it again

[Link](); // Clear the screen for gesture display

bool fingers[5] = {false, false, false, false, false};

bool gestureDetected = false; // Flag to check if any gesture is detected

for (int i = 0; i < 5; i++) {

if (potValues[i] >= GESTURE_THRESHOLD) {

fingers[i] = true;

gestureDetected = true; // Set to true if any finger crosses the threshold

String message = "";

if (gestureDetected) { // Only process gesture if one is detected

if (fingers[0] && fingers[1] && !fingers[2] && !fingers[3] && !fingers[4]) {


message = "Need Assistance";

} else if (fingers[3] && fingers[0] && !fingers[2] && !fingers[4] && !fingers[1]) {

message = "Washroom";

} else if (fingers[4] && !fingers[0] && !fingers[1] && !fingers[3] && !fingers[2]) {

message = "I am Thirsty";

} else if (fingers[3] && !fingers[0] && !fingers[1] && !fingers[2] && !fingers[4]) {

message = "I am Hungry";

} else if (fingers[3] && fingers[2] && fingers[1] && !fingers[0] && !fingers[4]) {

message = "Thank You";

} else if (fingers[0] && fingers[4] && !fingers[1] && !fingers[2] && !fingers[3]) {

message = "Hello";

} else if (fingers[0] && fingers[1] && fingers[2] && fingers[3] && fingers[4]) {

message = "Bye";

} else {

message = "No Message";

} else {

message = "No Gesture"; // Display this when no gesture is detected

}
if (message != lastMessage) {

displayMessage(message);

lastMessage = message;

void handleAutomationMode() {

if (firstDisplay) {

[Link]();

[Link](0, 0);

[Link]("Mode:");

[Link](0, 1);

[Link]("Automation");

delay(2000); // Delay to allow the user to see the mode message

firstDisplay = false; // Set the flag to false so we don't show it again

[Link](); // Clear the screen for automation display

bool fingers[5] = {false, false, false, false, false};


bool gestureDetected = false; // Flag to check if any gesture is detected

for (int i = 0; i < 5; i++) {

if (potValues[i] >= GESTURE_THRESHOLD) {

fingers[i] = true;

gestureDetected = true; // Set to true if any finger crosses the threshold

String message;

if (gestureDetected) {

if (fingers[0] && !fingers[1] && fingers[2] && fingers[3] && fingers[4]) {

digitalWrite(relayPin, HIGH); // Turn on the device

message = "Device ON";

} else {

digitalWrite(relayPin, LOW); // Turn off the device

message = "Device OFF";

} else {
message = "No Gesture"; // Display when no gesture is detected

digitalWrite(relayPin, LOW); // Ensure device is off when no gesture is detected

if (message != lastMessage) {

displayMessage(message);

lastMessage = message;

void displayMessage(const String& message) {

[Link]();

[Link](0, 0);

// Check if the message fits in the first line

if ([Link]() <= 16) {

[Link](message);

} else {

// If the message is too long, split it into two lines

[Link]([Link](0, 16)); // First line


[Link](0, 1); // Move to the second line

[Link]([Link](16)); // Rest of the message

You might also like