Noob needs a bit of help

did you look into the example's you wil just need to modifiy the existing code by adding some if else 0r while do conditions
see here http://www.arduino.cc/en/Reference/Else
http://www.arduino.cc/en/Reference/DoWhile