[Robot Arm Control Project 3] Joystick Input Value Verification Test

· 2019-11-14 · 3
Through this practice, you will understand analog input and joystick sensors. Materials Required: Arduino, 1 Joystick Content: Connect the joystick to the Arduino and verify through the serial monitor how analog input values are received according to joystick operation. Through this practice, you will observe how analog values change when the joystick is moved, and based on this, determine the range of analog values that will allow the servo motor to operate. Circuit connection is as follows. Although the actual practice used a 9-pin joystick, since it is not available in Fritzing, a commonly used 5-pin joystick was used in Fritzing. The joystick enables analog input on the X and Y axes, and digital input is possible when the button is pressed on the Z axis. The VER pin, which handles the X axis, was connected to pin A0, and the HOR pin, which handles the Y axis, was connected to pin A1. Additionally, the SEL pin, which handles Z axis digital input, was connected to pin 4. The code is as follows. ``` #include //Header file inclusion const int X_AXIS = A0; //X axis analog input pin 0 designation const int Y_AXIS = A1; //Y axis analog input pin 1 designation void setup() { // put your setup code here, to run once: Serial.begin(9600); //Serial monitor use } void loop() { // put your main code here, to run repeatedly: int xVal = analogRead(X_AXIS); //Read X axis value int yVal = analogRead(Y_AXIS); //Read Y axis value int pushBtn = digitalRead(4); Serial.print("Btn : "); Serial.print(pushBtn); Serial.print(" "); Serial.print("X: "); Serial.print(xVal); Serial.print(" "); Serial.print("Y : "); Serial.println(yVal); delay(500); } ``` Operation Video
3
댓글 0
등록된 댓글이 없습니다.