For anyone interested, I am still working on my project as well.
To recap, I'm building a modular control panel system. Simply put, it comprises of a series of control panels (between 2-5 buttons per-control panel) that can be screwed into modular bays, allowing you to effectively build a dashboard.
I've almost finished the first fully functional prototype, I just need a spare 5 minutes to actually create the circuit board - which is part of why it has taken me a little longer, as I have designed a circuit board that you can actually make yourself using electric paint, which not only means you don't have to solder anything, but obviously hugely reduces costs.
The prototype panel is landing gear control. It comprises of;
1 Landing Gear toggle switch
3 Landing Gear LEDs (they flash on when landing gear is lowered, and off when raised)
1 Ship Light button with built-in LED (the button is lit when lights are on, off when off)
2 reset buttons (resets the LED's in case the game and control panel become out of sync)
I've managed to reduce it all down to just 3 pins on the Leonardo (plus 5v and GND pins), so you could actually connect 6 panels to one board (that's up to 30 buttons).;
1 analogue pin - handles up to 5 buttons (code could be changed to handle more)
1 digital PWM pin - handles flashing LED
1 digital pin - handles static LED
It works by using a resistor tree on the 1 analogue pin. Each control panel will have a specific resistor as R1 which determines the panel (i.e. Landing Gear panel might have a 100 ohm resistor as R1). There are then up to 4 additional resistors in series when a switch. So when button 1 is pressed, the 1 analogue pin will read the resistance of the first resistor - in this case, 100 ohm. It knows that 100-500 ohms is the landing gear panel range, and 100=button 1. When button 2 is pressed, 2 resistors are now live giving a resistance of 200 ohm, so again it knows it's landing gears and button 2. etc etc.
A second panel's R1 might be a 1k ohm resistor, so it knows anything between 1000 to 1400 are the 5 buttons on that panel.
The pins are also all specific so that the Leonardo knows what LED pins to fire. So in the above example, the landing gear panel is Panel 1 - so it's 1 analogue pin will be plugged into the Leonardo's A0 pin. It's standard digital pin will be plugged into digital pin 2. It's PWM pin into digital pin 3. Panel 2's anlogue would be A1. It's digital pin would be 4. It's PWM would 5. etc etc.
So in the Leonardo code, it's sniffing for the resistance values of all the 5 analogue pins. If it finds resistance on analogue pin 0, and the resistance falls within the landing gear range, and matches button 1, then it knows it needs to flash LED's on digital pin 3 on or off.
Sounds a little complex, but it's actually a very simple system.
Once I have it working correctly, I'll make all of the source code available along with printable panel faces so you can make the panel yourself, as well as printable circuits so you can make your own circuit boards! How's that for DIY?
