EasyManua.ls Logo

SunFounder PiCar-4WD - Page 68

Default Icon
72 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
63
keyboard_control.py
In the code, we use readchar and readkey to get the input state of the key, then we assign some functions
to the keys by using if statement.
import picar_4wd as fc
import sys
import tty
import termios
import asyncio
power_val = 50
key = 'status'
def readchar():
……
def readkey(getchar_fn=None):
getchar = getchar_fn or readchar
……
def Keyborad_control():
while True:
global power_val
key=readkey()
if key=='6':
……
elif key=='4':
……
if key=='w':
……
elif key=='a':

Related product manuals