--- AutoLock.py ---
# - * - coding: windows-1251 - * -
import serial
import os
ser = serial.Serial ('COM3', 9600) # Here you need to put your port
while 1:
s = ser.readline (). strip () # Read the line and remove the line breaks
# print (s) # uncomment for debugging
if s == 'Bye!': # if a person is gone, lock the system
os.system ('rundll32.exe user32.dll, LockWorkStation')
---
Under Ubuntu, it worked successfully with changes in 2 lines: the port opens like this:
ser = serial.Serial ('/ dev / ttyUSB0', 9600)
The machine closes like this:
os.system ('gnome-screensaver-command --lock')
A small video showing the work:
PS About my experiments with Arduino, I am still writing on the blog arduino-ru.blogspot.com , but there will be reports in the form of reports, and I plan to post more detailed descriptions on Habr with the analysis of source codes and schemes. In particular, I will be glad to do this if it is interesting to someone. Are there people in the audience who are close to software, but who want to understand a little bit of self-made hardware? Or vice versa, those born with a soldering iron in their hands, but never got close to the microcontrollers? In general, I want feedback - waiting for comments good and different :)