#define switch_1 1
#define adj_sw A0
#define max_del 500
int getdelay();
void setup() {
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(switch_1,INPUT);
pinMode(adj_sw,INPUT);
}
void loop() {
int val = getdelay();
if(digitalRead(switch_1)==true){
digitalWrite(11,HIGH);
delay(val);
digitalWrite(11,LOW);
digitalWrite(10,HIGH);
delay(val);
digitalWrite(10,LOW);
digitalWrite(9,HIGH);
delay(val);
digitalWrite(9,LOW);
digitalWrite(8,HIGH);
delay(val);
digitalWrite(8,LOW);
}
}
int getdelay(){
double voltage = analogRead(adj_sw);
return voltage/1023*max_del;
}