const int pins[] = { 13 , 12 , 11};
const int startingPosition = 0;
int currentPosition;
void setup() {
// put your setup code here, to run once:
for ( int i = 0 ; i < 3 ; i++){
pinMode(pins[i] , OUTPUT);
}
currentPosition = 2;
moveLED(currentPosition);
}
void loop() {
// int lastPosition
// put your main code here, to run repeatedly:
// for ( int i = 0 ; i < 3 ; i++){
// digitalWrite(pins[i] , HIGH);
// delay(1000);
// digitalWrite(pins[i] , LOW);
// }
// for ( int i = 2 ; i >= 0 ; i--){
// digitalWrite(pins[i] , HIGH);
// delay(1000);
// digitalWrite(pins[i] , LOW);
// }
// if(currentPosition)
delay(2000);
int newPosition = moveLeft(currentPosition);
moveLED(newPosition);
currentPosition = newPosition;
}
int moveRight(int currentPosition){
return currentPosition + 1 ;
}
int moveLeft(int currentPosition){
return currentPosition - 1 ;
}
void moveLED(int position){
digitalWrite(pins[position] , HIGH);
}