EasyManuals Logo

Freenove Ultimate Starter Kit User Manual

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #140 background imageLoading...
Page #140 background image
Chapter 12 Joystick
140
www.freenove.com
support@freenove.com
28
29
30
31
32
33
34
35
36
37
38
39
40
41
time.sleep(0.01)
def destroy():
bus. close()
GPIO. cleanup()
if __name__ == '__main__':
p rint ('Program is starting ... ')
setup()
try:
loop()
e xcept KeyboardInterrupt:
destroy()
In the code, configure Z_Pin to pull-up input mode. In while cycle of loop, use analogRead () to read the
value of axis X and Y and use GPIO.input () to read the value of axis Z, then print them out.
w hile Tr ue:
val_Z = GPIO. input(Z_Pin) #read digital quality of axis Z
val_Y = analogRead(0) #read analog quality of axis X and Y
val_X = analogRead(1)
print ('value_X: %d ,\tvlue_Y: %d ,\tvalue_Z: %d'%(val_X,val_Y,val_Z))
time.sleep(0.01)

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Freenove Ultimate Starter Kit and is the answer not in the manual?

Freenove Ultimate Starter Kit Specifications

General IconGeneral
BrandFreenove
ModelUltimate Starter Kit
CategorySingle board computers
LanguageEnglish