I am very new to the Arduino and may have bitten off more than I can chew.
I have an Arduino Uno with an I/O shield attached.
My project is a 12 volt inverter charger with a generator start feature that consists of a relay output the contacts are closed when the charger would like the generator to run and are open when the charger would like the generator to not run.
My plan is to connect that set of contacts to a input on the I/O shield. And use two relay outputs from the I/O shield to operate a wireless remote for my generator. The remote has 2 buttons a start and stop that need to be pressed for about 10 seconds to either start or stop the generator.
The code needs to monitor the state of the relay contacts on the charger and close the appropriate output on the I/O shield to either start or stop the generator.
The problem I having is the relay outputs on the charger are normally open then when call for generator to start they close and remain closed until it is time to stop.
I have not been able to find a way to stop my code from just continually activating one or the other outputs depending on state of input.
Any help would be great. This is where i am at
Hello
Well, I guess the used delay´s will terminate the needed realtime behaiviour of your sketch.
At least your sketch needs a time handler, based on the BWOD example to be found inside the IDE.
There is an example sketch in the IDE that I think will help you. It's called "state change detection" in the "digital" menu. Study that and ask any questions you need to. I realise you do not need to count anything, but that sketch demonstrates the important principal of how to not simply detect the state of an input but the changing of it's state.
The way I interpreted @trvsndrsn 's description, there is one input, which indicates demand for power from the charge controller. My guess is that the the charge controller contains a relay which it can use to switch on some external power source to recharge the battery. @trvsndrsn wants to use those relay contacts like a switch connected to an Arduino input. It concerns me that INPUT_PULLUP is not used and we don't have a schematic indicating if any external pull-up/down resistor is connected, so the input may be floating. There are two outputs, connected to relays. Those relay contacts activate two buttons on a remote control for a generator to start or stop the generator. @trvsndrsn said these buttons need to pressed for 10s, which seems like a long time, and the sketch simulates pressing them for only 0.5s.
I hope you checked the label on the bottom of the ball for the words "dishwasher safe". The cleaning chemicals could make the surface of the ball permanently cloudy!
pressing the start button turns the engine on and holds the starter on for as long as the button is pressed. pressing the stop button turns the engine off
I have been trying to get the state change detection to work for weeks now. The problem is the input does not change state. Basically the input button is pushed and held.
I feel I need a second condition that would prevent the outputs from activating continuously. But with no other available input from any devices it would need to be code based.
you'd like to press a button to both power the engine and power a starter motor. when the button is released, the starter is un-powered but the engine remains on
and when you press the stop button, you'd like the engine to be un-powered so that it stops
Actually I took apart the wireless remote used to start the generator and removed the microswitches from the circuit board and replaced with wires so that the relay outputs on the I/O shield can activate the start or stop on the remote
So I guess to simplify this I need if input pin 2 goes low then output pin 8 goes high for x amount of time then go low then ignore the input from input pin 2 (that is still being held low, this is the part i cant figure out) Then if input pin 2 goes high then output pin 9 goes high for x amount of time then go low then ignore the input from input pin 2 (that is now being held high). The code and wiring I have now works and everything starts and stops the way it should. The problem is the buttons on the remote are basically pressed every 2 seconds until the batteries are dead which renders the whole system useless.