for some reason in this program i made it will delay when switching from pin 4 to 3 ( right when the program begins a new loop) and i have no idea why!
however there are no error messages caused by the program
int sensor = 0;
void setup() {
// the delay also happens upon start up right here
//set all used pins to OUTPUT mode
pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
pinMode(8,OUTPUT);
}
void loop() {
//read the state of potentiometer
int s = analogRead(sensor);
//turn on led, wait for the amount of time equal to the potentiometers position, then turn the next led on //while turning off the previous one
digitalWrite(3,1);
delay(s);
digitalWrite(3,0);
s = analogRead(sensor);
digitalWrite(4,1);
delay(s);
digitalWrite(4,0);
s = analogRead(sensor);
digitalWrite(5,1);
delay(s);
digitalWrite(5,0);
s = analogRead(sensor);
digitalWrite(6,1);
delay(s);
digitalWrite(6,0);
s = analogRead(sensor);
digitalWrite(7,1);
delay(s);
digitalWrite(7,0);
// check for a new potentiometer position
s = analogRead(sensor);
//then do the same proccese with the leds in reverse
digitalWrite(8,1);
delay(s);
digitalWrite(8,0);
s = analogRead(sensor);
digitalWrite(7,1);
delay(s);
digitalWrite(7,0);
s = analogRead(sensor);
digitalWrite(6,1);
delay(s);
digitalWrite(6,0);
s = analogRead(sensor);
digitalWrite(5,1);
delay(s);
digitalWrite(5,0);
digitalWrite(4,1);
delay(s);
digitalWrite(4,0);
//it delays right here for some reason!
}