Last active
October 18, 2020 13:10
-
-
Save RobolinkTeknoloji/6e0b775ffaa876a91088ca9ec04e48e6 to your computer and use it in GitHub Desktop.
Arduino Joystick Shield Buton ve Joystick Kontrol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define joyx A0 | |
#define joyy A1 | |
#define buton_a 2 | |
#define buton_b 3 | |
#define buton_c 4 | |
#define buton_d 5 | |
#define buton_e 6 | |
#define buton_f 7 | |
#define joy_buton 8 | |
void setup() | |
{ | |
pinMode(buton_a, INPUT); | |
pinMode(buton_b, INPUT); | |
pinMode(buton_c, INPUT); | |
pinMode(buton_d, INPUT); | |
pinMode(buton_e, INPUT); | |
pinMode(buton_f, INPUT); | |
pinMode(joy_buton, INPUT); | |
Serial.begin(9600); | |
} | |
void loop() | |
{ | |
//Joystick x-y eksenleri | |
Serial.print(" ||| "); | |
Serial.print("X: "); | |
Serial.println(analogRead(joyx)); | |
Serial.print(" ||| "); | |
Serial.print("Y: "); | |
Serial.println(analogRead(joyy)); | |
// a b c d Butonları | |
Serial.print(" ||| "); | |
Serial.print("a: "); | |
Serial.println(digitalRead(buton_a)); | |
if(digitalRead(buton_a) == LOW) | |
{ | |
Serial.println(" A'ya basıldı"); | |
} | |
Serial.print(" ||| "); | |
Serial.print("b: "); | |
Serial.println(digitalRead(buton_b)); | |
if(digitalRead(buton_b) == LOW) | |
{ | |
Serial.println(" B'ye basıldı"); | |
} | |
Serial.print(" ||| "); | |
Serial.print("c: "); | |
Serial.println(digitalRead(buton_c)); | |
if(digitalRead(buton_c) == LOW) | |
{ | |
Serial.println(" C'ye basıldı"); | |
} | |
Serial.print(" ||| "); | |
Serial.print("d: "); | |
Serial.println(digitalRead(buton_d)); | |
if(digitalRead(buton_d) == LOW) | |
{ | |
Serial.println(" D'ye basıldı"); | |
} | |
//Sağ Seçim Butonu | |
Serial.print(" ||| "); | |
Serial.print("Sag: "); | |
Serial.println(digitalRead(buton_e)); | |
if(digitalRead(buton_e) == LOW) | |
{ | |
Serial.println(" SAĞ'a basıldı"); | |
} | |
//Sol Seçim Butonu | |
Serial.print(" ||| "); | |
Serial.print("Sol: "); | |
Serial.println(digitalRead(buton_f)); | |
if(digitalRead(buton_f) == LOW) | |
{ | |
Serial.println(" SOL'a basıldı"); | |
} | |
//Joystick Tıklama Butonu | |
Serial.print(" ||| "); | |
Serial.print("Click: "); | |
Serial.println(digitalRead(joy_buton)); | |
Serial.println(" ||| "); | |
if(digitalRead(joy_buton) == LOW) | |
{ | |
Serial.println | |
(" Joystick butona basıldı "); | |
} | |
delay(1500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment