Need help with easiest program ever.

In a 'Hail Mary' throw to solve a problem, I purchased an Arduino MEGA 2560. I thought this would be easy to program but as soon as I saw C+++ I dipped out!
I have zero programing skills and do not wish to acquire any. If I need to pay someone to do write this program, then so be it. It should be rather easy, I hope!

Arduino 1.8.10
Arduino MEGA 2560
12V supply (Car battery in a car - could see 14V?)
Pin 01 - Read Voltage (1V - 4V)
Pin 02 - Read Voltage (1V - 4V)
Pin 03 - Read Voltage (1V - 4V)
Pin 04 - Read Voltage (1V - 4V)
Pin 05 - Read Voltage (1V - 4V)
Pin 06 - Read Voltage (1V - 4V)

When switch (mounted in car) is OPEN(normally):
Pin 07 - Jumper to Pin 01
Pin 08 - Jumper to Pin 02
Pin 09 - Jumper to Pin 03
Pin 10 - Jumper to Pin 04
Pin 11 - Jumper to Pin 05
Pin 12 - Jumper to Pin 06

When switch (mounted in car) is closed:
Pin 07 - Supply Voltage (1.68V)
Pin 08 - Supply Voltage (3.37V)
Pin 09 - Supply Voltage (2.78V)
Pin 10 - Supply Voltage (2.22V)
Pin 11 - Supply Voltage (2.90V)
Pin 12 - Supply Voltage (2.10V)

If I purchased the wrong Arduino, or if there is a better way to do the above, any input would be appreciated! TIA


How many relays did you buy and what are their specifications?


and TBD it seems!

What sort of relays do I need? I have not even considered needing them.

Would this work?

NOYITO 6-Channel Relay Module 5V 12V 24V High Low Level Trigger with Optocoupler Isolation Relay Load AC 250V 10A / DC 30V 10A (DC 5V, Blue),paur:ClkAsKraX97b_F3dRyMqtau1zWKCZL09d_FGD8LwrCsHr22upbYqOlj5-3cPRveg-ZJJ1xK3r_5YpTKyM52wgArXvV1q9b6-Iax39ExlPj3TxF6UOz4n-OZmsBIZAFPVH70i07ja_iQIKqBH21VrFt5pjodRRQ,prmr:1&sa=X&ved=0ahUKEwiyyt3piuHmAhVZWs0KHSPgD2wQ8gIIuQM

Sorry for all the questions, I'm learning.

I see the need for relays, but this would require SPDT relays from what I read. I need to switch between two power sources.

The code for the Arduino should be:

When switch (mounted in car) is OPEN(normally):
Do nothing.

When switch (mounted in car) is closed:
Pin 01 - Supply Voltage (5V to power relay)
Pin 02 - Supply Voltage (5V to power relay)
Pin 03 - Supply Voltage (5V to power relay)
Pin 04 - Supply Voltage (5V to power relay)
Pin 05 - Supply Voltage (5V to power relay)
Pin 06 - Supply Voltage (5V to power relay)
Pin 07 - Supply Voltage (1.68V)
Pin 08 - Supply Voltage (3.37V)
Pin 09 - Supply Voltage (2.78V)
Pin 10 - Supply Voltage (2.22V)
Pin 11 - Supply Voltage (2.90V)
Pin 12 - Supply Voltage (2.10V)

Hopefully the supply voltage will have enough amperage coming from the Arduino to trick my onboard computer.

Switch will be a 5V supply.


Without sounding stupid, what are you trying to do with all these switches and relays?

Slow down, take a breath, think and express your needs objectively.
All i can see so far - is you’ve chosen the tools to address a requirement, but haven’t told us what that requirement is.

I’ve got an 04’ Mercedes E55 AMG with airmatic suspension. All I want to do is release the air out of the airbags when I am parked. I don’t want to change the normal driving ride height. Apparently no one has tried this, that I could find.
First, I tried to figure out how to simply release the air out of the airbags, but that was a no go.
Here is my solution:
The car has three level sensors with four wires going to each sensor.
1 - Ground
2 - 5V supply when system is on
3 - 2.5 volts coming back from sensor (voltage increases when car height increases.
4 - 2.5 volts coming back from sensor (voltage decreases when car height increases.

I want to insert the Arduino between the level sensors and duplicate the signals from the level sensors during arduino off scenarios.

When I flip my switch, I want the voltages from the sensors to be turned off and my new voltages sent to the on board computer instead.
This should trick the car into thinking it is too high and it will do all the work needed to lower the car to the ground.
Then I can turn the car off and walk away leaving it slammed.
I understand the implications and the unnecessary wear and tear on the air compressor and shocks, but I am on a mission. I have not been able to find anyone who has attempted this before and there seems to be no other way to accomplish this.

Thanks guys for your help.


The car has three level sensors with four wires going to each sensor.
1 - Ground
2 - 5V supply when system is on
3 - 2.5 volts coming back from sensor (voltage increases when car height increases.
4 - 2.5 volts coming back from sensor (voltage decreases when car height increases.

I think you're misunderstanding the sensor outputs.
I'll guess that pins 3 & 4 are differential (for noise immunity), and possibly an RS485 buss with data (try looking at it with a scope).

I expect you'll hit some substantial problems when you start faking signals.
Not to mention voiding your insurance etc.

Can you DRAW out your intended schematic (you'll need to do it sooner or later).
Also if possible see if you can link to the sensor datasheets.
Currently, I think youre going at this the wrong way with relays & switches, but that's just my opinion.

"not been able to find anyone who has attempted this before"

I doubt you're the first in 15 years, and there's probably a reason.
Happy to advise, if we have enough info to do it PROPERLY and safely, but no liability..
Do you have any references of how & why the system works normally ?

I don’t have a scope, but I see what you mean with it possibly sending data.
Doesn’t data run over AC current instead of DC? I have a power probe IV and it shows no AC current or PWM, just DC power.

I’m not finding the data sheet for the sensor. Part number is 0105427717 or 9168513

It’s a 2004 car so there is no warranty and I’m not sure what liability you are speaking of.

Can someone just write the code for the above so I can test?

If it doesn’t work, I will purchase a replacement level switch and run the Arduino and relays through it to simulate the signal I need.

@lastchancename: I agree; this looks like a sensor with a differential output centered at 2.5V (neutral). Emulating this will require a differential signal. I don't think it's a CAN signal or the levels would be changing too fast for him to measure.

@OP: it's not impossible, but I think you'll need to change your approach a bit.

If I understand you correctly, there are two operational states:
Normal: car works as it did before the Arduino
Modified: Arduino provides fake level signals.

In the Normal mode, you just need to pass the signals through: a DPDT relay or a pair of SPDT relays per sensor will do this just fine.

In the Modified mode, you need to decide what level you want to emulate and provide that voltage instead. Determining how to do this depends on whether you want to send fixed or variable level signals to the body management computer or not.

Either way, it's not hard to explain how to do it, but that "fixed or variable" bit needs to be decided on.

Also, I see six contacts on the airmatic sensor but you only mentioned 4 of them.

Great explanation!
I did purchase some SPDT relays and they are en route for the "normal" mode.

I had no idea that fixed or variable level signals existed and have no idea what I actually need or how to test for what I need.

That being said, do I have the option of both with the Arduino? (MEGA 2560)

I would hope my onboard computer would only require a fixed signal. I was planning a cheaper solution to use a breadboard with resistors and relays so that I could achieve the same results with how I want to send voltages. But, no know about fixed and variable level signals, that is probably not an option either...

I really appreciate the help from you guys! I am new to electronics.

Warranty != Insurance

Doesn't data run over AC current instead of DC?

i think you need more advice than we can give in this situation.
It sounds interesting, but needs hands on.

If I understand this properly, you are planning to modify the air bags that are there to save your live. I assume that would void any manufacturer's warranty. I wouldn't hire someone from this list to do that. I certainly wouldn't hire me. Instead, I would find someone who knows about airbags and has testing facilities, hence the ability to produce a secure product. I would expect to pay through the nose.

Are you serious? The airbags?

I came here to ask for some help writing some basic code. Like, the most basic ever I would think.
Why are you all are over complicating this.

I'll write the code myself.

maybe you think that everyone is 'overcomplicating' because, as you said, you do not understand exactly what you are trying to do. to emulate whatever signal comes from a sensor one must first know exactly what the signal is. it may be a PWM or a CAN signal. You can only understand the nature of the signal with an oscilloscope, and even with the scope you must be able to read the measurement and understand its meaning. That said, you can simply build a a voltage divider that gives you the desired voltage and try to apply that to the car computer to test if your idea is working. no need for any arduino, and also no guarantee that the car computer will not be damaged by that.
As a last word, I would not personally drive a car that may just drop to the floor while im on the motorway because something went wrong with the program or arduino board itself (to use an arduino in a car, you must go to a long way to protect it from EMI)

I came here to ask for some help writing some basic code. Like, the most basic ever I would think.

You still haven't even described what it is you really want the Arduino to do. The actual program flow. All you gave is a bunch of inputs and outputs, and that quite poorly described to boot.

It seems all you want is to provide either a sensor signal or a self-determined voltage to an input of some controller. In that case the whole Arduino is in fact redundant. All you need for that is a switch and a bunch of relays, to switch the signal lines from sensor to voltage divider supplying that signal voltage.

That is, provided of course that the signals you mention are indeed just that, a steady voltage! Not a PWM signal, not some kind of digital communications signal, not a balanced signal, not a current signal, not something else entirely... all of which can come up as a steady voltage on a basic multimeter, and many of which are more likely than a simple voltage which is very susceptible to noise.

The problem is that you don't seem to have a clue of what you're actually working with, or if you do, you're not offering us that all important piece of information. At the very least you should connect a scope to the signal, and study what it REALLY looks like. That failing you have to dig up a detailed data sheet of the actual sensors you use, in which the signal is described.

You are correct, I have no idea what I am doing and I am in way over my head. But I'm going to keep swimming.

I ordered a breadboard and some resistors and will build a voltage divider after more thought. I wanted to send a fake signal to the onboard computer from the Arduino, but that voltage sent wouldn't be grounded back to the Arduino and would never complete the circuit. I think...

I do apologize for not knowing what I am doing and getting frustrated with my lack of knowledge in this subject. But, I know a solution is out there and I will find it.

I used to be a plumber by trade, I've learned more about electronics in the past week than my whole life.

Everyone, calm down! He's not doing anything more complex (actually far less) than what low-riders do with switches and knobs. It's not for for restraint air-bags, it's for ride height adjustment: I have the same thing on the F250 truck in my driveway but it's controlled with manual switches, not the body-management computer.

I realize that a lot of you are worried about modifying things on cars, but people (yours truly included) do this kind of stuff all the time with absolutely no professional training. In a lot of cases, you're flying blind and have to figure it out as you go.

This is a guess, but considering the measurements you provided and looking at some of those sensors online, it looks like they're differential-output potentiometers. I'm basing that on how they look and how cheap they are. If so, then you could easily emulate the signals with resistors as you stated. Ideally, you'd have a service manual with wiring diagrams: that can often be very helpful. I haven't searched for one, but it's worth a try.

The problem you're having with other posters is that asking questions is a skill in itself so it can be hard to explain exactly where you need help. You didn't respond to my previous post, so I have no idea if I'm on the right track or not. If you don't respond to people's comments, then no one gets any feedback on what they said and then they get frustrated and everybody shuts down.

So let's take a deep breath, take arduinos completely out of the equation and I'll ask one question: have you tried applying a simulated ride height signal (using the voltages you measured) to the controller to see how the suspension responds?

I'm sorry, I thought I responded to all your comments!

Yes, this is for a vehicle ride height system that will only be modified when the car is parked. During normal driving, the relays will remain in the "off" position and the normal signals from the vehicle height sensors will go straight to the computer. (but still through the relay, so potential failure there, but even a loss of signal should not affect the ride height)

I do have the wiring diagrams for the air ride system and that is what I am working off of. I am quite sure the sensors are potentiometers and that is why I was just trying to send a false voltage. Thank you for looking into those sensors online.

Hopefully I can eliminate the need for the Arduino with the resistors in a voltage divider.

I have not tried applying a simulated signal yet, but I will this weekend.

I purchased:
Bread board kit with various components
Rigol DS1054Z (I have never used a scope, nor have any business using one, but I would like to learn)

These will be delivered sometime Sunday, so I will have to wait a few day to play around.

Thank you for the help, I would be going down the wrong road without you!