/*How to use the joystick module.
*Serial monitor readings.
*Read the code below and use it for any of your creation
*/
void setup() {
Serial.begin(9600);//enable serial monitor
}
void loop() {
int joy = analogRead(A0);//get analog value (0-1024)
int joy1 = analogRead(A1);//get analog value (0-1024)
String x = "x axis ";//creating string variable
String y = "y axis ";//creating string variable
Serial.print(x + joy);//print x axis value
Serial.print("\t");//tab space
Serial.println(y + joy1);//print y axis value
Serial.println( "");//space
delay(100);//delay
}
No comments:
Post a Comment