help!!!

trintyfearon:
thank you Paul for helping me understand. I'm new to all of this and feel a little less clueless now :). I now that asking for "line by line" was unnecessary.

Sorry about the snark. I suppose that was unnecessary, too - you didn't know what you were asking.

What perhaps you actually needed was:

Line 2 contains a declaration of an array of 6 bytes, and initialises them to pin numbers. There will presumably be an led on each of these pins. curentLED is an index into this array. it is set initially to 0.

setup() runs through that array and sets each of those ins to being an output. It also sets 'change time' to the current value of millis.

loop is executed thousands of times every second. Each time, it reads a potentiometer, and treats the value in it (which will be a value from 0-1023) as a number of milliseconds. If the number of milliseconds between the current time and changeTime is >= this value, it calls changeLED() and updates changeTime. This has the effect of calling changeLED every X milliseconds, according to where the potentiometer is.

changeLED clears all of the LEDs, and then lights the LED whose pin is indexed by currentLED in the ledPin array. This has the effect of turning one LED on, as specified by currentLED.

It then updates current LED. To do this it bounces the number from end to end. It does this by holding a value 'direction', which indicates which way currentLED is moving, and by checking for a direction change when currentLED exceeds 9 (going up) or is less than 0 (going down). This is a bug - it will cause the value of currentLED to bounce between 0 and 9, but the ledPin array only has six elements. when currentLED is anywhere between 6 and 9, unexpected things may happen.

When currentLED is equal to (say) 7, changeLED will attempt to light the LED whose pin number is 7 bytes from the start of the ledPin array. But because the ledPin array is 6 elements long, this memory location could contain any old thing - we don't know. Consequently, changeLED will invoke digitalWrite with a pin number that could be pretty much anything. It might be some pin that the UNO doesn't have. It might be one of the other LEDs. It might be pin 0 or 1, which would interfere with serial communications.

The same comments apply to setup(), which also runs past the end of the array.