Uncategorized

python or pyserial running a bit slow and delayed?


i am making some kind of flight stick with a throttle console thing that runs elite frontier 2 on a raspberry pi zero w, problem is getting the flight stick and throttle to work. how my setup works is using a arduino to get values from a joystick with a wii nunchuck ducktaped to it, (but right now am only trying to test out the buttons) then it sends a string if a button was pressed and also sends the joystick values through serial to the raspberry pi where then a python script gets the values and string, problem is its pretty delayed or just wont recognize all the time. dont know if the problem is pyserial or python it self or my zero w. (i have tried this originally on my laptop and it worked perfectly)

heres the really simple code

Code: Select all

import serial
import re


SerialObj = serial.Serial('/dev/ttyACM0', 115200)


while True:
    data = SerialObj.readline()

    if data == b'ZBUTTON PRESSED\r\n':
        print('zButton pressed')

    if data == b'CBUTTON PRESSED\r\n':
        print('cButton pressed')
 



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *