Sometime ago I went to a newspaper library and there were many newspaper in a film format. I was impressed. Here, you can see the newspapers moving a knob, and in that moment, I said to myself, "I need this to read PDFs, e-books, and to see images."
First StepsOnce the program is written in Arduino for programing the Infineon 3D magnetic sensor, please follow the steps listed in this link:
https://github.com/Infineon/XMC-for-Arduino
Arduino ProgramThe Arduino program only uses an axis, but if you use two axes, the control will be better. Additionally, the Infineon 3D magnetic sensor has the rotary knob.
Control using these movements:
#include <Tle493d.h>
Tle493d Tle493dMagnetic3DSensor = Tle493d();
void setup() {
Serial.begin(9600);
while (!Serial);
Tle493dMagnetic3DSensor.begin();
Tle493dMagnetic3DSensor.enableTemp();
}
void loop() {
Tle493dMagnetic3DSensor.updateData();
float x;
int range=20;
int range2=40;
x=Tle493dMagnetic3DSensor.getX();
if(x<=-range && x>=-range2){Serial.println("i");}
if(x<=-range2){Serial.println("I");}
if(x>=range && x<=range2){Serial.println("d");}
if(x>=range2){Serial.println("D");}
delay(50);
}
Python ProgramThe Python program uses the library PyAutoGUI and serial for translating the serial message of the Arduino into PC commands:
import pyautogui
import serial
import time
Ser= serial.Serial('COM16', 9600)
print("Conectado")
while True:
while (Ser.inWaiting() == 0):
pass
valueRead = Ser.readline()
if valueRead==b'i\r\n':
print("<")
pyautogui.press('left')
if valueRead==b'I\r\n':
print("<<")
pyautogui.press(['left','left','left'])
if valueRead==b'd\r\n':
print(">")
pyautogui.press('right')
if valueRead==b'D\r\n':
print(">>")
pyautogui.press(['right','right','right'])
time.sleep(0.1)
Watch out, the serial port need be the same as your Infineon, which in my case is "COM16."
FinalIf all is OK, you should move PDFs, see images, and e-books with the rotary knob.
Comments