Need some pointers on some code

Please work on indentation. I'm having trouble reading what the loop() does. It seems like either a function definition was missing after the loop and before the first, or there is one extra bracket in the middle.

Also, if you are reading a potentiometer, you can't really trust that it's steadily at 0 for a long period of time. It could keep switching between states P and R. Does it do anything if sensorReading was > 678? It would seem to keep the previous state, whatever it was.

You can shorten the code by wrapping the digitalWrites into a function with the 7 pins' states and the delay as parameters. That's 2 or 8 parameters, your choice.