Skip to content

Instantly share code, notes, and snippets.

@halit
Created July 2, 2012 15:20
Show Gist options
  • Save halit/3033748 to your computer and use it in GitHub Desktop.
Save halit/3033748 to your computer and use it in GitHub Desktop.
Remote Pc Controller via Arduino,Python and Xdotool
#!/usr/bin/env python
import os
import serial
# Halit Alptekin - www.halitalptekin.com - Remote Pc Controller via Arduino,Python and Xdotool
# Blog Post: http://www.halitalptekin.com/arduino-ile-basit-pc-kontrolu.html
# Video: http://www.youtube.com/watch?v=7cbUqbsQyto
SERIAL_PORT = '/dev/ttyACM1'
SERI_BAUDRATE = 9600
SERI_BYTESIZE = 8
SERI_PARITY = 'N'
SERI_STOPBITS = 1
SERI_TIMEOUT = 0.2
SERI_BUFFER_SIZE= 1024
def seriBaglan():
bag = serial.Serial()
bag.port = SERIAL_PORT
bag.baudrate = SERI_BAUDRATE
bag.bytesize = SERI_BYTESIZE
bag.parity = SERI_PARITY
bag.stopbits = SERI_STOPBITS
bag.timeout = SERI_TIMEOUT
bag.open()
return bag
bag = seriBaglan()
while 1:
gelen = bag.readline()
for gl in gelen:
gl = int(gl)
print gelen
g1 = gelen.find("1")
g2 = gelen.find("2")
if g1 == 0:
os.system("xdotool click 4")
if g2 == 0:
os.system("xdotool click 5")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment