Nedzib Sastoque Rangel
Published © GPL3+

Visualization Control for PDF or Image Files

A rotary control using Infineon 3D magnetic sensor and Python for images or PDF files, or anything right and left movement.

BeginnerFull instructions provided1 hour930
Visualization Control for PDF or Image Files

Things used in this project

Hardware components

3D Magnetic Sensor 2Go
Infineon 3D Magnetic Sensor 2Go
×1

Story

Read more

Code

Arduino

C/C++
#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

Python
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)

Credits

Nedzib Sastoque Rangel

Nedzib Sastoque Rangel

6 projects • 13 followers
#UDistrital Electronics student, I love programming, domotic, create prototypes and learn new things

Comments