I have an arduino which gives me numbers from a potentiometer (300-600), device /dev/ttyACM0 baudrate 9600.
I want to use these numbers as a 1-axis joystick.
My system is archlinux and X-Displaymanager.
I've done it with python and uinput:
#!/bin/env python2
import serial
import time
import uinput
ser = serial.Serial('/dev/ttyACM0', 9600)
events = (uinput.BTN_JOYSTICK, uinput.ABS_X + (0, 255, 0, 0))
device = uinput.Device(events)
device.emit(uinput.ABS_X, 128, syn=False)
while True:
value = ser.readline()
valuecorrect = value.strip()
valuecorrect = int(valuecorrect)/4
print valuecorrect
device.emit(uinput.ABS_X, int(valuecorrect))
For the calibration I use jstest-gtk.