ahem nur ein kleiner hinweis.
es muss heise
if(switched==1) {
}

alternativ kann man auch einfach
if(switched) {
}

schreiben