Messing around with arduino, and I made a line of LEDs where I can "Control" a single HIGH led with a joystick. I can "move" this HIGH led left and right on the line: GIF | Gfycat
int led[] = {2,3,4,5,6,7,8,9,10,11,12,13};
void setup() {
Serial.begin(9600);
for (int i = 0; i < 12; i++){
pinMode(led[i], OUTPUT);
digitalWrite(led[i], LOW);
}
}
void loop() {
int xAxis = analogRead(A0);
int yAxis = analogRead(A1);
int count = led[0];
Serial.println(xAxis);
xAxis = map(xAxis, 0, 1020, 0, 11);
for (count ; count < 14; count++){
digitalWrite(led[xAxis], HIGH);
delay(1);
digitalWrite(led[xAxis], LOW);
}
This all works as intended. But when I tried to get the opposite effect, all I did was switch the digitalWrites HIGH and LOW expecting to get control of a single LOW led and the rest would stay HIGH. that being said, the LOW led doesn't fully turn off: GIF | Gfycat
int led[] = {2,3,4,5,6,7,8,9,10,11,12,13};
void setup() {
Serial.begin(9600);
for (int i = 0; i < 12; i++){
pinMode(led[i], OUTPUT);
digitalWrite(led[i], LOW);
}
}
void loop() {
int xAxis = analogRead(A0);
int yAxis = analogRead(A1);
int count = led[0];
Serial.println(xAxis);
xAxis = map(xAxis, 0, 1020, 0, 11);
for (count ; count < 14; count++){
digitalWrite(led[xAxis], LOW);
delay(1);
digitalWrite(led[xAxis], HIGH);
}
Any help would be greatly appreciated.