Maybe I have missed it, but you do not appear to read the switch. I'd have expected a digitalRead( 6 ) somewhere.