how to use toggle switch

On a toggle switch you have 3 pins

I will call these from left to right T1, T2 and T3

Connect T1 to 5V
Connect T3 to GND
Connect T2 to Pin 8

in your code, read pin 8 and it will be high(5V) OR low(GND - 0V)