我想为Arduino制作一个简单的记忆游戏。但是我想使用操纵杆选择闪烁的LED而不是按钮。
我处于项目的早期阶段,但我的Y轴不会读取,我无法解决问题。
//Joystick
const int X_pin = A4;
const int Y_pin = A5;
int Joy_Waarde;
//leds
const int led_Rood = 13;
const int led_Groen = 12;
const int led_Blauw = 11;
const int led_Geel = 10;
//componenten
const int buzzer = 4;
int X_Value = 0;
int Y_Value = 0;
void setup() {
pinMode (led_Rood, OUTPUT);
pinMode (led_Groen, OUTPUT);
pinMode (led_Blauw, OUTPUT);
pinMode (led_Geel, OUTPUT);
pinMode(buzzer, OUTPUT);
Serial.begin(9600);
randomSeed(analogRead(A0));
Serial.println("Het spel is begonnen!");
}
void loop() {
X_Value = analogRead(X_pin);
Y_Value = analogRead(Y_pin);
if (X_Value == 1023) {
digitalWrite(led_Groen, HIGH);
} else {
digitalWrite(led_Groen, LOW);
}
if (X_Value == 0) {
digitalWrite(led_Blauw, HIGH);
} else {
digitalWrite(led_Blauw, LOW);
}
if (Y_Value == 1023) {
digitalWrite(led_Geel, HIGH);
} else {
digitalWrite(led_Geel, LOW);
}
if (Y_Value == 0) {
digitalWrite(led_Rood, HIGH);
} else {
digitalWrite(led_Rood, LOW);
}
}
希望你们现在有关于它的事情!提前谢谢!
答案 0 :(得分:0)
它有效,这是布线的事情!
谢谢!