Anyone help me with some code?

Hi guys i was wondering if someone could please write some code for me.

What i have is an input conected to A1 and 3 outputs connected between A2 and A7

So what i need is as long as A1 is receiving an inout of 5 volts the arduino to keep all outputs open as in don't send out a signal

But if that 5v reduces to 4v connect A2 and A3 together as in close the switch.

Once A1 receives the reading of 5v again re open the switch and no longer send out a signal

But if that 5v reduces to 3v connect A4 and A5 together as in close the switch

Once A1 receives the reading of 5v again re open the switch and no longer send out a signal

But if that 5v reduces to 2v connect A6 and A7 together as in close the switch

Once A1 receives the reading of 5v again re open the switch and no longer swnd out a signal

I hope this makes sense thanks in advance And i apologize if this is in the wrong forum i could not find the correct spot for it.

It doesn't make sense to me, too much is assumed in your description.

The sub-forum 'Gigs and Collaborations' is where you should have posted. Don't repost there, send a message to a moderator and ask them to move this post.

I don’t understand what you mean by “keep all outputs open as in don’t send out a signal” and “connect A2 and A3 together as in close the switch”.

The code will probably be trivial, but alas I can’t help since I don’t understand.

This might be an XY problem?

(If you’re serious about getting someone to code this for you, as distinct from trying yourself and asking for help, this is probably the better forum. You could ask a mod to move it by hitting Report to Moderator on your post.)

edit… like Chris said :wink:

I messaged the moderator thanks

As for the confusion all i am wanting is for A1 to be an input and then have 3 switches (A2-A3,A4-A5,A6-A7)

So when A1 receives a certain voltage it will close a certain switch.

Mack3y41: As for the confusion all i am wanting is for A1 to be an input and then have 3 switches (A2-A3,A4-A5,A6-A7)

So when A1 receives a certain voltage it will close a certain switch.

That's just a re-statement of what you already said.... it still makes no sense to me.

As is so often the case, I think the quality of help will increase if you explain your problem (properly), not your solution (badly).

I think what he is asking for is at the appropriate time, pins A2 and A3 get connected together, A4 and A5 and A6 and A7 get connected together. Not going to work that way, but I think that is being asked.

gpsmikey: I think what he is asking for is at the appropriate time, pins A2 and A3 get connected together, A4 and A5 and A6 and A7 get connected together. Not going to work that way, but I think that is being asked.

Yes, and that's why I think this is an XY issue. He has a half-formed solution in mind, for a problem he hasn't explained.

(edit....anyhoo, I'm off for my weekly parkrun (ok, walk) so I'll be back in a few hours to see if there's any progress.)

Yes that is correct to what i am asking is that not possible its probably just me but it seems very simple to me i just dont know how it works i have done alot of research to find a result but could not find anything.

I dont really know what you mean by a better explanation.

So it is not possible to make 2 pins into a switch?

Explain your problem, not your half-formed solution....

I'm off for my run.... laters....

Mabye it would be better to explain exactly what im doing

So what i have is an input from my steering wheel controls in my car the steering wheel has 3 buttons there is 1wire from the three buttons the wite is always sending a current of 5volts unless a button is pushed if i push the power button it changes the current to 4volts volume up changes the current to 3volts and volume down changes the current to 2volts.

Now what i want is the arduino to take the input and then close a circuit those circuits are to my tablet now:

The power and volume buttons on my tablet have been replaced with wires so there are 2 wires per button and when they are touched together it acts as if the button is pushed.

So what i want is to conect all 7 wires to the arduino and as stated above depending on the input voltage close the "switch" (as in touching the wites together) so if i push power on the steering wheel the arduino will read that the current has changed from 5volts to 4 volts and will "touch the two power wires from the tablet together.

I hope this explains it a bit better thanks

Also once i release the power button i want the arduino to read that the current has changed back to 5volts and "untouch the 2 wires together"

Typically one does not input a button press into an Arduino data pin, by shorting it to another data pin.

If I want to sense if a button is pressed or not, I connect one side of the button to ground, and the other to the pin. Then using the function, digitalRead(pin) I can check if the button is pressed or not.

Is that what you want to do?

Pairs of inputs on the arduino don't really work like switches. What you would do is have the output from the pin operate an electronic device that acts as a switch - a relay, a FET, a transistor - something that can take whatever load you are putting across it.

Mack3y41:
Maybe it would be better to explain exactly what I’m doing

Oh, what a novel idea! :roll_eyes:

Always the best - in fact basically the only way to get a useful answer.

To emulate the switches on the tablet, you use a 74HC4066 which is controlled by the Arduino outputs - it contains four switches. Its ground (and the Arduino) must be connected to the negative of the tablet battery.

I do not like the idea of your Arduino connected both to the tablet and the steering wheel. An optocoupler could be used to read (with a suitable resistor - say 10 k) the voltages from your steering wheel and its output could be connected between an Arduino analog input and ground, using the INPUT_PULLUP function to provide current so you can read it.

Mack3y41: a current of 5volts

You need to back up a bit, and do some reading up on the fundamentals of electricity, methinks.

Basically you need to do what Paul__B said. However, instead of the 4066, I would use an optoisolator since there's a good possibility that the switches you want to control are matrixed and you can't ground reference them.

OK. I know I said a bunch of stuff you don't understand, but here's the gist: Read your input on A1 as expected, and use optoisolators to "bridge" the switch contacts.

I've solved this type of problem before and that's typically the simplest solution.

I was going to post some code, but now I can see that the OP doesn’t want any help.

Offensive post (to which ChrisTenone is referring) has been removed.

ChrisTenone: I was going to post some code, but now I can see that the OP doesn't want any help.

[quote author=Nick Gammon link=msg=2704224 date=1460257508] Offensive post (to which ChrisTenone is referring) has been removed. [/quote]

Damn time difference.... seems I missed the good part?

Saw it Jim, I don't think the OP wants our help. .