Im very new to arduinos and coding and what I want to make is a button box with switches. What I want it to do is when I flip the switch on it sends a single keystroke and when I flip the switch off It sends another keystroke.
Anyone know how to code this that could plz help me. Im trying to make a dashboard for my American Truck Simulator and I already found a code for the gauges but all I need is the switches.
This code that johnwasser put in will work for switches. So when I turn on the switch it will push a key that I want. Lets say ''t''. When I flip the switch on it will hit ''t'' one time and then when I flip the switch off it will hit ''t'' one more time. Also to make the arduino do this or have these key strokes it has to be a Leonardo or a micro?
If you're worried about IO pins, you're not limited to just the capabilities of the Arduino itself. You can increase the number of digital pins you have available with external chips like a shift register (74HC165 and 74HC595 are popular) or port expander (like MCP23008). Datasheets for each are attached.
Basically just a copy paste job, adding in extra inputs in setup and variables to keep track of the state of each extra switch then adjusting the keystrokes within the Keyboard.write function.