Hi everyone, I am fairly new to arduino and I have little to no experience with coding. I’ve tried to read tutorials but certain aspects of it are hard to understand in such a short time. I can sort of follow how the code’s output can be, but I get lost so easily.
Basically I have 2 linear actuators set up each with their own HY-SRF05 UltraSonic Sensors and I’m trying to use 3 buttons to change the height as well as remember the set height. If I click the top button, the actuator moves up, if I click the bottom button, the actuator moves down, if I keep the center button pressed for more than a second, the arduino remembers the height, and if I click the center button once, the height gets adjusted to the remembered height. If I click the center button again and the height is equal to the remembered height, it returns to the lowest height setting.
I hope that logic isn’t too confusing, but in reality it’s very simple. I have the top and bottom buttons physically hooked up to relays to drive the actuators, but my problem is using the center button to remember a height and change its height automatically based on the longevity of the press.
As for the code, I’ve downloaded a library to read heights in real time and print them to the serial monitor, I just don’t know how to maneuver the code in order to work with the data and to work in certain situations. Thank you
Show us a good schematic of your circuit.
Show us a good image of your wiring.
Give links to components.
Posting images:
Use CTRL T to format your code.
Attach your ‘complete’ sketch between code tags, use the </> icon in the posting menu. [code]Paste your sketch here[/code]
pcbbc:
Indirectly through the Arduino I hope?
If the switches are directly connected to the relays then that is totally half baked IMHO.
I have output pins from the arduino wired to the inputs of the relays. I also have buttons going to each respective input on the relay to do a manual lift and drop. If I click the button, 5V runs to the input and activates the relay. I hope that clears things up a bit
I’ve taken a look at the code provided. Thank you for doing that. I don’t quite follow the logic, but I changed around the pin values and it somewhat works with the relays that I have set up.
Below is the code that simply regulates both actuators making sure that they both maintain the same height. I want to include button states that once pressed and held for like 3 seconds, then it would remember the value. When I click the button then it would recall the remembered state and change the value of the height. If I wanted to overwrite the remembered value, then I should be able to, but I don’t know how to remember serial monitor values and to manipulate them in the code. Sorry i’m very new to coding and it’s very hard to follow when you don’t have a trained mind like yours’
r0haan:
I have output pins from the arduino wired to the inputs of the relays. I also have buttons going to each respective input on the relay to do a manual lift and drop. If I click the button, 5V runs to the input and activates the relay. I hope that clears things up a bit
Nope (well, not to me anyway); I diagram would though.
Yep, you’ve got the switches wired directly to the relays controlling your actuators.
Arduino should sit between all switches and relays.
There should be no direct interaction between switch and relay/actuator.
Trying to make a digital control system and other way is crazy.