//here you can change speed of the effect, it can be faster or slower, as you wish
int time_between_blinks = 50;
void setup() {
//here we are setting up all pins as an outputs for LEDs
pinMode(0, OUTPUT);
pinMode(1, OUTPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
}
void loop() {
//thats the for loop, the first parameter is a value that is equal to 0, the loop
//will work as long as the value of a will be higher or equal to 10 (second parameter)
//and at the end we are incrementing a by 1
int volume = analogRead(A0);
volume = map(volume, 0, 1023, 0, 10);
for(int a = 0; a <10; a++){
if(volume >= a){
digitalWrite(a, HIGH);
}else{
digitalWrite(a, LOW);
}
}
}
// potentiometer is connected to A0 anolog input as its value changes ,the output of PwM also changes