Skip to content

Commit bb5af17

Browse files
committed
added python code
1 parent 7eaab15 commit bb5af17

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

presentationPointer.bat

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
chcp 65001
2+
set PYTHONIOENCODING=utf-8
3+
python presentationPointer.py
4+
pause > nul

presentationPointer.py

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
"""
2+
presentationPointer (c) 2019 by Michał Stojke, LICENSE: MIT
3+
4+
Simple code which allows to interpret received IR codes from Arduino UNO into PC
5+
keyboard codes. Just run this code and PowerPoint and have fun! EKHM... if you
6+
have a SAMSUNG TV REMOTE, otherwise you need to look at define section and change
7+
key codes accordingly to yours remote controller.
8+
9+
"""
10+
11+
import serial
12+
import time
13+
from pynput.keyboard import Key, Controller
14+
15+
# define section
16+
com_port = 'COM6' # port on which Arduino is connected
17+
baud_rate = '9600' # baud rate of connection
18+
back_key = '-22951' # key code from remote which turn back slide
19+
forward_key = '18105' # key code from remote which turn forward slide
20+
f5_key = '5865' # key code from remote which turn on presentation mode
21+
esc_key = '-19381' # key code from remote which turn of presentation mode (ESC key)
22+
23+
connection = serial.Serial(port=com_port, baudrate=baud_rate)
24+
keyboard = Controller()
25+
26+
last_key = ''
27+
28+
while True:
29+
try:
30+
data = connection.readline()[:-1].decode("utf-8", "ignore").strip()
31+
print("Received IR code: {0}".format(data))
32+
if data == back_key:
33+
print('Clicked: Back Key')
34+
keyboard.press(Key.left)
35+
if data == forward_key:
36+
print('Clicked: Forward Key')
37+
keyboard.press(Key.right)
38+
if data == f5_key:
39+
print('Clicked: F5 Key')
40+
keyboard.press(Key.f5)
41+
if data == esc_key:
42+
print('Clicked: ESC Key')
43+
keyboard.press(Key.esc)
44+
except serial.SerialException as e:
45+
print("Disconnect of USB -> UART occured. \nRestart needed!")
46+
quit()
47+
except TypeError as e:
48+
print("ERROR")
49+
quit()
50+
51+
connection.close()

0 commit comments

Comments
 (0)