# Coding an ignition switch

**URL:** <https://forum.arduino.cc/t/coding-an-ignition-switch/1190041>\
**Category:** General Guidance\
**Created:** [November 17, 2023, 1:11am UTC](https://forum.arduino.cc/t/coding-an-ignition-switch/1190041 "2023-11-17T01:11:16Z")\
**Posts on this page:** 1\
**Showing post:** 21

<div class="post-metadata">

**Author:** ![alto777](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/alto777/32/317385_2.png) [@alto777](https://forum.arduino.cc/u/alto777)\
**Post date:** [November 18, 2023, 1:21pm UTC](https://forum.arduino.cc/t/coding-an-ignition-switch/1190041/21 "2023-11-18T13:21:53Z")

</div>

> [@davie56](#):
>
> instead I want the game to see when the key is turned to the OFF position (not just in the OFF position).

If the game has no way to react to a switch opening, you will have to handle that yourself.

You need to use state change detection and grab the opportunity it would afford to react to either (or both) the opening and the closing of some switch.

Wire the ignition switches separately, not on the matrix, and handle them with state change detection.

With the facts about opening and closing of the two equivalent switches, spoon feed the equivalent in button presses.

When you see the ignition switch part for "OFF" contacts open up, send a button press to the start/stop part of the game.

I've made it sound easy and it may be. I have no experience with button boxes and how games listen for whatever they produce. I do not know how start/stop,operates, I would guess it's a momentary switch that turns the engine off and on alternately with each press.

See this post and the thread it lives on for the state change detection idea:

> [@Storing Button State](https://forum.arduino.cc/t/storing-button-state/1185825/6):
>
> I normally point ppl to the IDE Examples/02.Digital/StateChangeDetection sketch, and the article that goes with it. Here is an adjustment and reduction of that example, which actually works. And somewhat less code to slog through to get the basic idea. One of the original's flaws is that it does not handle Try it here [Wokwi\_badge] [State Change Detection](https://wokwi.com/projects/380600410686023681) This code also follows the IPO model, which is a very useful and very used model for many the things we do with the Arduino. [IPO Pr…](https://en.wikipedia.org/wiki/IPO_model)

HTH

a7

---

_[View the full topic](https://forum.arduino.cc/t/coding-an-ignition-switch/1190041)._
