Xiaobo qq:463431476
Reprint please indicate the author
Python Source Code
Import Rpi.gpio as gpio #human-computer-interactionimport curses import time from curses Import Wrapper gpio.setmode (GPIO). BCM) #left_moto_goGPIO. Setup (GPIO. Out) #IN1 gpio.setup (GPIO). Out) #IN3 #left_moto_backgpio.setup (12,gpio. Out) #IN2 gpio.setup (25,gpio. Out) #IN4 #right_moto_goGPIO. Setup (GPIO. Out) #IN5 gpio.setup (GPIO). Out) #IN7 #right_moto_backgpio.setup (17,gpio. Out) #IN6 gpio.setup (8,gpio. Out) #IN8  STDSCR = CURSES.INITSCR () stdscr.clear () while True: ch = stdscr.getkey () #EXIT if ch = = ' E ': Curs Es.endwin () break # forward & nbsp if ch = = ' W ': gpio.output (27,gpio. High) gpio.output (18,gpio. High) &NBSp gpio.output (12,gpio. Low) gpio.output (25,gpio. Low) gpio.output (22,gpio. High) gpio.output (23,gpio. High) gpio.output (17,gpio. Low) gpio.output (8,gpio. Low) time.sleep (0.3) gpio.output ( 27,gpio. Low) gpio.output (18,gpio. Low) gpio.output (22,gpio. Low) gpio.output (23,gpio. Low) gpio.output (12,gpio. Low) gpio.output (25,gpio. Low) gpio.output (17,gpio. Low) gpio.output (8,gpio. Low) # backward if ch = = ' s ':  &Nbsp; Gpio.output (27,gpio. Low) Gpio.output (18,gpio. Low) Gpio.output (12,gpio. High) Gpio.output (25,gpio. High) Gpio.output (17,gpio. High) Gpio.output (8,gpio. High) Gpio.output (22,gpio. Low) Gpio.output (23,gpio. Low Time.sleep (0.3) Gpio.output (2 7,gpio. Low) Gpio.output (18,gpio. Low) Gpio.output (22,gpio. Low) Gpio.output (23,gpio. Low) Gpio.output (12,gpio. Low) Gpio.output (25,gpio. Low) &NBSP Gpio.output (17,gpio. Low) Gpio.output (8,gpio. Low) # Turn right if ch = = ' d ': &N Bsp gpio.output (27,gpio. High) gpio.output (18,gpio. High) gpio.output (12,gpio. Low) gpio.output (25,gpio. Low) gpio.output (17,gpio. High) gpio.output (8,gpio. High) gpio.output (22,gpio. Low) gpio.output (23,gpio. Low) time.sleep (0.3) Gpio.output (27,gpio. Low) gpio.output (18,gpio. Low) gpio.output (22,gpio. Low) &NBsp Gpio.output (23,gpio. Low) gpio.output (12,gpio. Low) gpio.output (25,gpio. Low) gpio.output (17,gpio. Low) gpio.output (8,gpio. Low) # Turn left if ch = = ' A ': gpio.output (22,gpio. High) gpio.output (23,gpio. High) gpio.output (17,gpio. Low) gpio.output (8,gpio. Low) gpio.output (12,gpio. High) gpio.output (25,gpio. High) gpio.output (27,gpio. Low) gpio.output (18,gpio. Low) time.sleep (0.3) Gpio.output (27,gpio. Low) gpio.output (18,gpio. Low) gpio.output (22,gpio. Low) gpio.output (23,gpio. Low) gpio.output (12,gpio. Low) gpio.output (25,gpio. Low) gpio.output (17,gpio. Low) gpio.output (8,gpio. Low) Below is the test video
Raspberry Pi2 Smart Car source code and test video