0
\$\begingroup\$

I want to use a key switch in conjunction with an Arduino, so that I can detect when the key is turned by reading HIGH on a digital input pin. This is the one I have found that matches the aesthetic I am after:

Momentary Key Switch

I originally assumed I could just use this as I normally would with a standard push button switch: when the switch is closed, the current flows which I can easily detect in the code.

However, I'm now wondering if there's more to it as it is rated for 12 or 24V DC and the Arduino only provides 5V. It seems to me like it should be as simple as if an electrical connection is made (when the key is turned) then the current will flow. Is there more to it that I'm missing, or are these simply upper voltage limits and therefore it shouldn't be a problem?

\$\endgroup\$
  • \$\begingroup\$ Yes, it's just a connection, you don't have to give it that much. \$\endgroup\$ – pjc50 Jan 9 '17 at 15:30
  • \$\begingroup\$ As you say, these are simply upper voltage limits and therefore shouldn't be a problem. \$\endgroup\$ – Steve G Jan 9 '17 at 15:34
  • \$\begingroup\$ Great, thanks guys. Any idea why it states both 12 and 24 if it is an upper limit? (Just curious) \$\endgroup\$ – kingraam Jan 9 '17 at 16:02
  • 1
    \$\begingroup\$ It only needs to state 24V. Intruder alarm systems work on 12V, fire alarm systems work on 24V, door access systems can be either. The switch is specified as 12 or 24V just to make it clear to installers of these systems. \$\endgroup\$ – Steve G Jan 9 '17 at 16:06
1
\$\begingroup\$

These key switches are just a regular switches, and the specified numbers are just upper voltage/current limits. It should work fine with Arduino.

The main possible problem is that a dirt (or grease) on the contacts may present some resistance, so if your Arduino is too sensitive it might accidentally register switch as closed while it is actually open. This is likely will not be a problem until the switch spends some time outside, under dew, rain and snow, but if it does become a problem, add a smaller pull-up resistor. The Arduino's integrated pull-up is 20-50K, and you may want to add 0.5-1K if you have problems with moisture.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.