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 #138 background imageLoading...
Page #138 background image
Chapter 12 Joystick
138
www.freenove.com
support@freenove.com
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
printf("setup wiringPi failed !");
return 1;
}
pinMode(Z_Pin,INPUT); //set Z_Pin as input pin and pull-up mode
pullUpDnControl(Z_Pin,PUD_UP);
pcf8591Setup(pinbase,address); //initialize PCF8591
while(1){
val_Z = digitalRead(Z_Pin); //read digital quality of axis Z
val_Y = analogRead(A0); //read analog quality of axis X and Y
val_X = analogRead(A1);
printf("val_X: %d ,\tval_Y: %d ,\tval_Z: %d \n",val_X,val_Y,val_Z);
delay(100);
}
return 0;
}
In the code, configure Z_Pin to pull-up input mode. In while cycle of main function, use analogRead () to
read the value of axis X and Y and use digitalRead () to read the value of axis Z, then print them out.
while(1){
val_Z = digitalRead(Z_Pin); //read digital quality of axis Z
val_Y = analogRead(A0); //read analog quality of axis X and Y
val_X = analogRead(A1);
printf("val_X: %d ,\tval_Y: %d ,\tval_Z: %d \n",val_X,val_Y,val_Z);
delay(100);
}

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