Wiring an On/OFF Toggle switch to Arduino Pro Micro

Hi,

Not sure how i would connect an on/off toggle switch to the arduino pro micro board. If someone could point me to some diagrams or anything that would help would be greatly appreciated. I'm just not sure what pins i will need to solder the cables onto the board.

Also will i need any other components or is the switch and the pro micro it?

Toggle switch i'm using - https://www.ebay.com.au/itm/1-x-12V-Heavy-Duty-Toggle-Flick-Switch-ON-OFF-Car-Dash-Light-Metal-SPST-12-Volt/202046732498?hash=item2f0aec78d2:g:to0AAOSw-0xYOrBb:rk:2:pf:0

Cheers.

What do you want to happen? switch off the whole board? if so you need to interrupt the supply to the board.
If you want to switch an input to the board on and off then the best way is to use an internal pull up input and the switch.

But it really does depend on what you are switching and why.

Kia Ora

Kiwi

What I want to happen is when the toggle is pressed I want it to activate a function in a game. So I am not quiet sure what i need to do.

One switch terminal to the Arduino GND, the other to any digital pin. Declare the pin with:

pinMode(n, INPUT_PULLUP); where n is the pin number.

var = digitalRead(pin) will set var to a zero when the contacts are closed, a one when open. If you want to reverse that logic, use:

var = digitalRead(pin) ^ 1; or
var = ! digitalRead(pin);

There are many ways to flip a bit in C, use what you understand and recognize.

Okay thanks for the help.