View Full Version : 5 position start key link2fs/arduino question.
Damo78
11-01-2015, 07:05 PM
Dear all
I've just received a 5 position key switch from tinterweb. I've popped a multimeter on the contacts and worked out which pin is connected to each rotation point of the key. My question is, setting this up for a Cessna fsx, via arduino. Would you recommend a digital input or analog output?
I'm very new to coding and electronics, perhaps choosing to run before I can crawl? My plan then is to map the input types to the relevent codes in Jim's amazing link2fs, (off/L/R/Both/Start). or just off and start if only available. Key is for a tractor I believe, (it's rather big but £8 rather than £130 I've seen them for), I'm possibly assuming incorrectly that this will work via 5v? Multimeter shows 5 seperate outputs so I'm thinking 5 switches (in my head).
Will this work for my intentions with link2fs?
Many thanks
Damo.
SimSupervisor
11-02-2015, 12:09 AM
The key switches are either on, or off. They don't have a variable output other than on or off. That is digital.
You will need to some debouncing on the inputs, one input per key position.
Damo78
11-02-2015, 03:24 AM
Many thanks SimSupervisor, that's a good thing for me to remember and of course it makes sense now. On/Off, High/Low = digital.
Lastly then (hopefully), l cannot find a data sheet for this, but assume it must need grounding. I can't seem to see a pin for this, but a little reading and I find 1 mention, that ground is the body of the lock. So should I just solder a ground to the metal casing? It's the Durite Ignition Switch 5 position, photo as follows.
Sorry if these questions seems silly, I'm still very much learning the ABCs.
http://www.mycockpit.org/forums/attachment.php?attachmentid=10927&stc=1
Thanks for another lesson!
Damo
SimSupervisor
11-02-2015, 11:32 AM
Do you have a voltmeter? Test the pins for continuity using the chassis for a gnd. Body for a ground is not the preferred approach but isn't unusual either. If it work just make sure to have something that is physically in contact with the body for the common pin and you're all set. One way to do that is with the fastener, having something bolted together with the switch, that can accommodate the wire. Soldering on the body can work but is prone to breaking.
BushPilotWannabe
11-02-2015, 07:29 PM
That is some switch. Please keep us posted.
hyamesto
11-02-2015, 08:39 PM
Hi everyone:
I do not agree with the solution using digital inputs.
Why? Because you'll need to use 5 digital inputs.
Why not use this connection? Only one analog input.
http://www.mycockpit.org/forums/attachment.php?attachmentid=10936&stc=1
You need programing the Arduino to react according the range values of the analog input.
Actual positions should be given as ranges, not a single value, to exclude false reacting - i.e. the 1st position when value is in range 0-200, the second position - value 300-700, the third position - value 800-1023
This way, is not mine, is from
http://svglobe.com/arduino/a_switch.html,
All credits to Vlad Sychev.
and there you can find others good examples, and adapt the Arduino script for FSX.
(The original web, is for X-Plane)
Regards
Horacio.
SimSupervisor
11-03-2015, 12:12 AM
That's an option, but I prefer keeping analogs for reading analogs... Arduinos have more digital than analogs, particularly the megas, and the digitals can be multiplexed.
Damo78
11-03-2015, 12:00 PM
Hi SimSupervisor, yes to the voltometer, (I assume it's the same as a multimeter). I' used it to check which pin is in the circuit with the key turns using the sound function on it, which was good, as the 'switches' don't run in number order bizarrely.
I'll rig something up to the breadboard later with the ground on the casing, via batteries I think, or the wife's computer...
Hyamesto, thanks for the input. This idea is similar to the lcd shield that I have, where the 6 buttons all output to A0 and are separated by differing resistance inputs. It is quite a good idea, but the coding gets a little complicated (for me) when trying to ascertain things between, less than up to and including a specific number, unlike just saying pin 23 does this, 24 does that etc. Good chip in however, thank you.