Arduino Leonardo Joystick/Gamepad emulation

hi,

I want to have a set of toggles and buttons like in this video: https://www.youtube.com/watch?v=7IV_xSDl4rE

but have no clue how to make the three way toggles work and how to code the buttons so windows gamepad controller recognize it.

please help. Thanks

oh and also, can I have a toggle set to off but it being recognised as a button being pressed in the software through code?

SP3T? You can wire the switch to have a different voltage level depending on position. Just use two resistors and wire them between the tabs. One position is GND, the middle position is half voltage and the third is Vcc. Now all you need to do is read it with AnalogRead.

HazardsMind:
SP3T? You can wire the switch to have a different voltage level depending on position. Just use two resistors and wire them between the tabs. One position is GND, the middle position is half voltage and the third is Vcc. Now all you need to do is read it with AnalogRead.

im sorry, im really new to this and ordered my ARDUINO yesterday, can you give me a example on how the code will look like?

Ok, but keep in mind this is not a full working code, it’s just a snippet.

int Toggle = analogRead( A0 );
const int overhead = 3;
// use either cases or if/else statements

if( Toggle == 1023) // Vcc 
{
   // your key command here
}

else if( (Toggle / 2) <= 512 + overhead || (Toggle / 2) >= 512 - overhead ) // Vcc / 2
{
  // another key command
}

else // GND
{
  // some other key command
}

HazardsMind:
Ok, but keep in mind this is not a full working code, it’s just a snippet.

int Toggle = analogRead( A0 );

const int overhead = 3;
// use either cases or if/else statements

if( Toggle == 1023) // Vcc
{
  // your key command here
}

else if( (Toggle / 2) <= 512 + overhead || (Toggle / 2) >= 512 - overhead ) // Vcc / 2
{
 // another key command
}

else // GND
{
 // some other key command
}

Ok thanks, so I can just copy this and use it for each pin i use for the three way toggles? And whats the meaning of vcc? And the things in the brackets if the starting lines? Im planning to have four three way toggles, what will the code look like then?

Thanks for your patience, im very new to this and my Arduino only arrived yesterday, lol

Yea, you can do that. But it would make things a little easier if you know how to turn it into a function. If not then don't worry about it.