I have some issues trying to assemble a code for a project. (very green with this code stuff)
my project objective is this.
open a flap by remote control the opening device being solar powered battery.
the layout is this
actuation is done by using a 12 volt micro linier actuator powered by a 12 volt battery using a external solar cell and charge controller. I am engaging the actuator with a litle RF device< KR2402A-1 it uses two relays that allow me to set it up for a reversing circuit press button A it opens Press button B in closes.
Now I need the RF device to work in latching mode so a momentary button push causes the actuator to run until it hits its internet limit switch, now this device will do just this but my issue is the power draw of the relays coils will be to much drain for the small solar system... enter Arduino I have a circuit now that employs an Arduino that receives the momentary out put from the RF relays and I desire to have the Arduino drive a separate relay board that will drive the actuator.
my issue is putting a program together to engage the relays using a timer so when the rf signal A closes the KR2402 relays the Arduino sees two pins with a closed circuit then Arduino tells the separate external relay to close for 10 seconds then release (giving the actuator enough time to reach its limits) thus saving power consumption. the added need is the program needs to cancel the loop if the opposite button is pushed and at the same time actuate that opposing relay circuit for 10 seconds . My er "programing" ability is very poor and I rely on the pre written programs in the Arduino files but nothing really fits my need. anyone able two direct me to how to do this?
(I could also use other rf devices with two channels not necessary the KR2402 its just what I have right now)
When you read the pinned post re 'How to get the most from the forum', you will discover the best start is to post a photo of your hand drawn wiring diagram. You are also expected to post all your code in code tags after doing an auto format.
Obviously you are a long way from there so let's try this.
Post a drawing of the contraption. Name the parts identical to your word salad.
After it is determined if it is feasible, someone will tell you to use a particular library, and you will find sample sketches in the library. Then, like many of us, you iterate on those samples and mix, match, and merge them until you finally get stuck. Now come back here and ask why X happened when I did Y, and I expected Z. Now we can proceed.
ok hopefully I am doing this as instructed. I simplify this circuit just to line out the needed script, on the picture two momentary switches are connected to pins 2 and 3 and two LED run off of pins 8 and 9
so I need pin 3 to make make pin 9 high for 3 second otherwise make pin 9 low but if pin 2 is pressed during this 3 seconds I need pin 9 set to low
and vice versa for pin 2
the following is the script put together from tinkercad. it works close to what I need but it is not turning off pin 8 when pin 9 is engaged during pin 9's 3 second loop and vice versa as I need.
You should use a different variable for each button state. Maybe button2state and button3state. Also, get rid of the delay in the code and learn to time it with the millis function. While you are delaying for 3 seconds, the code cannot proceed any further to read the other button. The delay BLOCKS any further code from running until 3 seconds (your delay time) is up. If you time the 3 seconds using millis, the code can continue to run and read the other button.
And also <HIGH is probably not gonna get you anywhere.
That is excellent progress. I am not going to analyze the failure mode bit I will point you to what you need to make it better/work. Look in the tutorials for topics along the line of doing several things at the same time and a second topic is state machines. BIG CLUE is do NOT use delay.
the pins can be configured to use an internal pullup resistor, the buttons simply wired between the pin and ground, the button is pressed when the pin is LOW
ok this works for the primary purpose I am still not having luck with interrupting the 3 second "loop" and starting the opposite 3 second "loop" by the pressing of the second button
I am studying into this "mills" situation to avoid the delay command which by the pointing out of some folks seems to be my issue.
this will (or a similar board) replace the pin 2 and 3 impute from momentary buttons on my original post. I can use a similar board with no relays just I/O outputs