I have purchased a UNO R3 board and stepper motor along with 2 push/pull solenoids but i do not have a clue how to write the code. I have read allof the guides but just cant get to grips with it. I basically need 1 solenoid to push whilst the other pulls and then vice versa. I need to be able to change the frequency of these movements. Any help would be much appreciated
You do NOT write an entire program at once. You write a little bit of code, and test it. Then, you write some more, and test that. Repeat until you have written all of the code.
What, EXACTLY, triggers the solenoid push/pull action?
How, EXACTLY, are you connecting the solenoids to the Arduino? Not directly, that is for sure.
How long does one solenoid push?
I need to be able to change the frequency of these movements.
Based on phases of the moon? The price of rice in China?
I will have a read through the guides you have attached and hopefully i can get some understanding of how to manage this. Below is a list of the hardware i have.
A logic level N channel MOSFET would, in my opinion, be a better choice of driver for the solenoid than an antique stepper driver. The coil current is listed at 1.1A which is on the very edge of the 298 capability.
I am quite happy to switch motors if i can get the code to work these. this motor must work as it does in the video above. I just need some help with the code as i dont even know where to start.
1.1A at 5V for the solenoids. No way you can connect them directly to the Arduino pins. Easiest is to use a relay board, or build your own circuit as described for the solenoid.
Using H bridge instead of relays for solenoids is quite un-orthodox.
For an H bridge you need 3 pins. Dual H bridge 6 pins.
Open library manger and search for L298N. You will find a few libraries. Install one of them and look at example code. Library manages the pins. I think the best way is to set motorspeed to 255 (avoiding pwm output to solenoids) and use motor enable/disable to control the solenoids.
Gabriel_swe:
Using H bridge instead of relays for solenoids is quite un-orthodox.
For an H bridge you need 3 pins. Dual H bridge 6 pins.
If you just want ON/OFF action or PWM in a single direction with an L298 you can control it with 1 pin. Bi-directional PWM needs either two PWM pins or 1 PWM pin and two direction pins.
The L298 drops nearly 2 Volts at 1 Amp so the supply voltage to the L298 will nee to be high enough to compensate. Supply voltage needs to be at least minimum solenoid pull in voltage + 2V.