// Initialize Bar Graph Variables:
int Tank = 10; // Initial value of Tank
int c = 0; // Initial value of c
void setup()
{
for(int i = 0; i < 12; i++)
{
pinMode(i, OUTPUT); // Set pins 0 to 11 as OUTPUT
}
}
void loop()
{
// Turn on the first 'Tank' number of LEDs
for(int i = c; i < Tank; i++)
{
digitalWrite(i, HIGH); // Turn on LED at pin i
delay(50); // Short delay between turning on each LED
c++;
}
delay(1000); // Wait for a second before changing Tank
Tank = 6; // Update the value of Tank
// If c is greater than Tank, turn off the LEDs from c down to Tank
if (c > Tank)
{
for (int i = c - 1; i >= Tank; i--)
{
digitalWrite(i, LOW); // Turn off LED at pin i
delay(50); // Short delay between turning off each LED
}
}
delay(1000); // Wait for a second before the next iteration
}