Code is not working for this thing.....

I’m trying to write code this circuit I set up and don’t have a book to refer to because this is from my mind. So, there are basically 8 LED’s next to each other on the breadboard and that’s pretty much it (aside ofcourse from all the connections to the digital pins and etc…). I don’t think there’s anything to worry about in terms of the hardware- I used for a previous project that was similar to this, but less complex when it relates to the pattern I’m currently trying to make happen. I’m trying to make a kind of “bounce chasing effect” where the LED’s are in “2 halves” (not literally but the code treats them as such) and they light up in a row and in such a way so that they look like they are “bouncing of each other”. Like, first, the 4th and 5th LED’s turn on and then off, and the next LED for both in opposite directions light up and off and it continues like this until the original middle LED’s are on and it repeats, and this would look like bouncing. Sorry if I can’t give a better explanation (maybe the code will tell you more). So, now, here is the code. I think the problem occurs at the end with “direction”:

byte ledPin1[] = {3, 4, 5, 6};
byte ledPin2[] = {7, 8, 9, 10};
int ledDelay = 100;
boolean direction;
boolean currentLED1 = 3;
boolean currentLED2 = 0;
unsigned long changeTime;
byte potPin = 2;


void setup(){
  for(int x=0; x<3; x=x+1){
    pinMode(ledPin1[x], OUTPUT);
    pinMode(ledPin2[x], OUTPUT);
    changeTime = millis();
  }
}

void loop(){
  ledDelay = analogRead(potPin);
  if((millis() - changeTime) > ledDelay){  
    changeLED();    
    changeTime = millis();
  }
}

void changeLED(){
  for(int x=0; x<3; x=x+1){
    digitalWrite(ledPin1[x], LOW);
    digitalWrite(ledPin2[x], LOW); 
  }
  digitalWrite(ledPin1[currentLED1], HIGH);
  digitalWrite(ledPin2[currentLED2], HIGH);
  currentLED1 += direction;
  if(currentLED1 == 3){direction = -1;}
  if(currentLED1 == 0){direction = 1;}
  currentLED2 += direction;
  if(currentLED2 == 3){direction = 1;}
  if(currentLED2 == 0){direction = -1;}
}

Look at the code in your post. Does it really look like that ?

Read http://forum.arduino.cc/index.php?topic=97455.0 in particular how to use code tags.

Ok, sorry about that. I fixed it now.

The code you posted does something. You did not describe what it actually does.

Your description of what it should do is abysmal.

  for(int x=0; x<3; x=x+1)
  {
    digitalWrite(ledPin1[x], LOW);
    digitalWrite(ledPin2[x], LOW); 
  }

How many LEDs have you got ?

Pluto1:
I’m trying to write code this circuit I set up and don’t have a book to refer to because this is from my mind.

think about using arrays to simplify your life. Notice the byte pattern in myMask…

compiles but not tested:

byte myMask[8] = {0b00000000, 0b10000001, 0b01000010, 0b00100100, 0b00011000, 0b00100100, 0b01000010, 0b10000001};
const byte ledPin[8] = {3, 4, 5, 6, 7, 8, 9, 10};
int ledDelay = 100;

void setup(){
  for(int x = 0; x < 8; x++)
  {
    pinMode(ledPin[x], OUTPUT);
  }
}

void loop()
{
  bounceLeds();
}

void bounceLeds()
{
  for (int j = 0; j < 8; j++)
  {
    for (int i = 0; i < 8; i++)
    {
      digitalWrite(ledPin[i], bitRead(myMask[j], i));
    }
    delay(ledDelay);
  }
}