#include <LedControl.h>
const int posX = A0;
const int posY = A1;
LedControl lc= LedControl(12, 11, 10, 1);
void setup() {
lc.shutdown(0,false);
lc.setIntensity(0,5);
lc.clearDisplay(0);
}
void loop() {
int x;
x = 0;
int y;
y = 0;
lc.setLed(0, x, y, true);
do {
if (analogRead(posX) > 1000) {
lc.clearDisplay(0);
++x;
if(x > 7) {
x--;
}
lc.setLed(0, x, y, true);
delay(100);
}
else if (analogRead(posX) < 100) {
lc.clearDisplay(0);
x--;
if(x < 0) {
++x;
}
lc.setLed(0, x, y, true);
delay(100);
}
}
while (515 < analogRead(posX) < 525);
do {
if (analogRead(posY) < 100) {
lc.clearDisplay(0);
++y;
if(y > 7) {
y--;
}
lc.setLed(0, x, y, true);
delay(100);
}
else if (analogRead(posY) > 900) {
lc.clearDisplay(0);
y--;
if(y < 0) {
++y;
}
lc.setLed(0, x, y, true);
delay(100);
}
}
while (485 < analogRead(posY) < 515);
}
This code is the code that moves the LED of the 8x8 dot matrix by the joystick.
When this code is executed, the X-axis moves normally at the 8x8 dot matrix, but the Y-axis does not.
I want to know which part is wrong.
And my English is not good, so I use a translator.
Therefore, we ask for your understanding as it may affect communication.
I'll change the question.
I changed the position of the code on the X-axis and the code on the Y-axis.
This time, the Y-axis moves, but the X-axis does not move.
It seems to be a problem because do while statement cannot be used at the same time.
What do you think there is?