It seems to be very easy if you told me some details
1 , which model of arduino to use the code with (uno, mega, nano ,.... etc)
2, The code take action when the switch gets on or when gets off or when when change from any case to the opposite
3, Are you aiming to sho the result on a display for example or to use it to take an action