Usage of Joystick With Arduino Mega R3
At my this project i tried to use a joystick. This component has five pins.
These are Vcc, Gnd, voltage reference 1, voltage reference 2 and switch input.
This joystick based on two potentiometers that gives an analog inputs to the
arduino. This analog signals have values between 0 to 1023.
If you use my connection ;
you will have 0,0 at right up corner and 1023,1023 at left down corner.
We also have a switch. If you press the joystick through
down it will be active.
Best wishes
/* Usage of Joystick With ARduino Mega * * Equipments : * 1 x Arduino Mega 2560 R3 * 1 x Jojstick * * My personal blog https://ozturkgokhan.com/ * This programme based from http://www.arduino.cc/ */ int joyPin1 = A1; // First analog input for Jostick int joyPin2 = A2; // Second analog input for Jostick int value1 = 0; // variable to read the value from the analog pin 0 int value2 = 0; // variable to read the value from the analog pin 1 void setup() { pinMode(joyPin1, INPUT); pinMode(joyPin2, INPUT); Serial.begin(9600); } void loop() { value1 = analogRead(joyPin1); delay(100); value2 = analogRead(joyPin2); delay(100); Serial.print("first value : "); Serial.println(value1); Serial.print("second value : "); Serial.println(value2); Serial.println("---------------------"); delay(1000); }
Ocak 29, 2015 tarihinde Arduino Mega, Graduation Project içinde yayınlandı ve Arduino, Arduinomega, Circuit, CODING, DIY, Electronics, final project of engineering, joystick, Project olarak etiketlendi. Kalıcı bağlantıyı yer imlerinize ekleyin. Yorum yapın.
Yorum yapın
Comments 0