Need help with loops and switches

void loop() {
val = digitalRead(switchPin);
Serial.println(val);
}

That's all that is repeating in your program.

It doesn't go down to your val() function, because it never leaves loop(). You have to call val() somewhere within loop.