74HC00
74HC00

Reputation: 9

LED pins high and low at the same time?

Can someone explain me why are they using the same variable "i" to determine which pins are high. I understood everything except the function block at barGraphDisplay. Like how can you set one pin at high and all the rest at low with only "i" ? The way I see it, the function chooses only one position of the array and evaluates it.

Schematic enter image description here

Code Block enter image description here

Upvotes: 0

Views: 141

Answers (1)

Justin Guerin
Justin Guerin

Reputation: 156

First, the variable i in barGraphDisplay is scoped to the function, so the variable i in loop() is not relevant.

Second, the call to digitalWrite is inside a for loop, so i isn't just one number, it's all values in ledCount. Additionally, it's inside an if / else block, so if i == ledOn then the LED is set to HIGH, otherwise LOW. But the same pin (denoted by the value of i) is never set to both states.

Upvotes: 1

Related Questions