Vehicle Chassis Controller

Hey everyone. I have an arduino Mega 2560 R3 and I have begin working on a vehicle chassis controller . the controller will use a Windows 10 interface to command the arduino calling functions within a modular programming approach. My questions are centered mostly around IO Expanders to add capability to the arduino mega. Problem is I have run out of Digital and Analog inputs and outputs and I require additional digital and analog inputs and outputs to complete my project. I have prepared a modular code design that I am prepared to share through IM if someone can help me with this design. The question is, Are there any IO expanders that can be referenced subsequently as 55, 56, 57, 58 ecs as the mega has 54 inputs and outputs without using binary or machine code with addresses to the next AVR?

I have a main loop calling several functions to added to my sketch. ActiveSuspension, ActiveAerodynamics, SequentialShifting, ClimateControl, InteriorLighting, ExteriorLighting, IgnitionControl, WindowMotorControl, WiperControl, and soon to be added SecurityControl.

You can control another arduino using the Wire library. You also have I2C too. However if you are just looking to output or input simple bits, then you can use a shift register. It will take up 3 of your arduino pins for the latch, data and clock pins on the SR.

Long story short, you have options, it's just a matter of how far you are willing to go.

You'll need to write a new abstraction layer that makes an arbitrary number of Arduinos appear as a single Arduino with additional I/O. The latency of the inter Arduino links will make the secondary Arduinos second class citizens.

HazardsMind: However if you are just looking to output or input simple bits, then you can use a shift register. It will take up 3 of your arduino pins for the latch, data and clock pins on the SR.

I second the shift register idea.

IMO, shift registers are just about the easiest chips to use. They're great for adding outputs to ta microcontroller. Parallel to serial shift registers can be used as inputs. Analog inputs can be added by using an external ADC chip.

Shift registers are daisychainable too. Write & read to them with the SPI pins (SCK, MOSI, MISO, and a latch pin, usually SS, so pins 50-51-52-53.

Running out of outputs on a MEGA is quite impressive. This must be a really complex thing.

A big consumer of outputs is LED displays. There are specialised driver chips for LEDs that can be used like a shift register. They can do 7-segment numerical displays as well as discrete LEDs. The MAX7219 is a good example. This is also useful because it has a proper constant-current drive and doesn't need individual resistors on the LEDs.

Inputs can be multiplexed. There are chips to do this for analog and digital. For adding analog inputs, I would add a SPI-based A/D converter. This can share the SPI control lines with the shift registers. The MCP3008 is one example to look at.

I've even used a MAX7219 as an input. I needed a lot of LEDs and inputs on a board so I had some of the 7219 outputs connected to switches and then all switches went to one Arduino input. By cycling the outputs, I could work out which switch was pressed.

I have never used up even all the I/O on an Uno, so I am impressed that you have found a Mega inadequate.

You have not said what you want all the I/O to do and I wonder if it would ease the design, development and debugging load to "modularize" the system with a number of Arduinos each dedicated to a particular activity.

I have some Sparkfun Pro-Micros which are cheap, small and use the 32U4 chip so that they have both USB and a spare USART which makes debugging and inter-board communication possible at the same time.

You could use one of them, or even a Mega with its 3 spare USARTs as the interface with the PC and to monitor the behaviour of the others.


I am kinda new to the arduino ide and programming in general but I can include a project file or Sketch so you can see what I am doing. (7.41 KB)

I will try the shift register path and come back to you guys once I have a working model. I would however like to share my sketch with someone to get an analysis on my coding methodology and logic.

I would however like to share my sketch with someone to get an analysis on my coding methodology and logic.

Feel free to post it here.
And please use the code button </> so your code looks like this and is easy to copy to a text editor

If the program is too long to post (hopefully not) you can add it as an attachment.


Here is the program. I couldn't save it all into the program test editor. Was definitely more than 9000 characters

Here goes nothing :o

For the paddle shifting Idea I am wanting to use Hydraulic solenoids and pressure supplied from the power steering pump to a custom manifold distributed to hydraulic actuators for shifting the transmission with pressure sensors on each side of the actuator and main distribution valve. This is for a Honda CRV transmission to go semi-sequential. I am going to need alot of help with this one for sure.

@Gotboost858, re. your report to moderator: You're kidding, right?

I am receiving info from a lot of different people who tell me not to post code online so I thought that I made a mistake posting my code here for everyone to see. I don't mean to be a dick just afraid and skittish everyone. Sorry. I have spent a lot of time trying to get this right and this is the largest program I have ever made. I am grateful for anyones help. I am still learning. Bad advise will come from those jealous of your accomplishments I guess. This person that told me not to post my code has been pissed off for awhile about his inability to even execute the blink program correctly. Sorry for the confusion

this is the largest program I have ever made

I can't see a program.

This is the code for the Vehicle Chassis Controller with functions called from the main loop() and a diagram I created for the Hydraulic Shifting System I would like to make for my race car.

Hydraulic_Shifting_Control.pdf (508 KB)

StephenDunn_MainLoop.pdf (180 KB)

Don't the delays affect the responsiveness?

Delays for the blinkers? or the delays between functions? I was going to use interrupts but this is the ruff code