4

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.

1 Answer 1

5

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.