Created
November 14, 2017 10:51
-
-
Save elktros/088c01e6605acecdaef8ee5481b4917b to your computer and use it in GitHub Desktop.
Python Code for the project Arduino based Hand Gesture Control of Computer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gesture control python program for controlling certain functions in windows pc | |
# Code by BalaAppu | |
# Website: www.electronicshub.org | |
import serial # add Serial library for serial communication | |
import pyautogui # add pyautogui library for programmatically controlling the mouse and keyboard. | |
Arduino_Serial = serial.Serial('com12',9600) # Initialize serial and Create Serial port object called Arduino_Serial | |
while 1: | |
incoming_data = str (Arduino_Serial.readline()) # read the serial data and print it as line | |
print incoming_data # print the incoming Serial data | |
if 'next' in incoming_data: # if incoming data is 'next' | |
pyautogui.hotkey('ctrl', 'pgdn') # perform "ctrl+pgdn" operation which moves to the next tab | |
if 'previous' in incoming_data: # if incoming data is 'previous' | |
pyautogui.hotkey('ctrl', 'pgup') # perform "ctrl+pgup" operation which moves to the previous tab | |
if 'down' in incoming_data: # if incoming data is 'down' | |
#pyautogui.press('down') # performs "down arrow" operation which scrolls down the page | |
pyautogui.scroll(-100) | |
if 'up' in incoming_data: # if incoming data is 'up' | |
#pyautogui.press('up') # performs "up arrow" operation which scrolls up the page | |
pyautogui.scroll(100) | |
if 'change' in incoming_data: # if incoming data is 'change' | |
pyautogui.keyDown('alt') # performs "alt+tab" operation which switches the tab | |
pyautogui.press('tab') | |
pyautogui.keyUp('alt') | |
incoming_data = ""; # clears the data |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment