Stepper motor "valve"

Hi guys, im new to Arduino so forgive me for my ignorance,
I need to make a sort of "valve" moved by a stepper motor, it has to move of 90 degrees when I turn on a switch and get back to the original position when I turn it off.
If possible id also like the Led's to indicate me the position of the stepper motor
Can anyone help me ?
Thanks


@elhad, your topic has been moved to a more suitable location on the forum.

Yeah but I need the program

is it mean you got every hardware you need for the project? ok, show it.

Hi,
Can you please tell us your electronics, programming, arduino, hardware experience?

If you want someone to write the code for you then you would be best to move this thread to
"Jobs and Paid Consultancy" for some help.

Tom.. :smiley: :+1: :coffee: :australia:

if you want some program, nothing else.
here:

/*Specifications
• Unipolar stepper with 0.1" spaced 5-pin cable connector
• 32 steps per revolution
• 1/16.025 geared down reduction
• 5V-12V DC suggested operation
• 9" / 23 cm long cable
• Holding Torque @ 12VDC: 250 gram-force*cm, 25 N*mm/ 3.5 oz-force*in
• Shaft: 5mm diameter flattened
• Dimensions: 28mm diameter, 20mm tall not including 9mm shaft with 5mm diameter
• Weight: 37g
  */
#include <AccelStepper.h>
#define HALFSTEP 8

// Motor pin definitions
#define motorPin1  3     // IN1 on the ULN2003 driver 1
#define motorPin2  4     // IN2 on the ULN2003 driver 1
#define motorPin3  5     // IN3 on the ULN2003 driver 1
#define motorPin4  6     // IN4 on the ULN2003 driver 1

// Initialize with pin sequence IN1-IN3-IN2-IN4 for using the AccelStepper with 28BYJ-48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

void setup() {
  stepper1.setMaxSpeed(1500.0);
  stepper1.setAcceleration(300.0);
  stepper1.setSpeed(200);
  stepper1.moveTo(10000);

}//--(end setup )---

void loop() {

  //Change direction when the stepper reaches the target position
  if (stepper1.distanceToGo() == 0) {
    stepper1.moveTo(-stepper1.currentPosition());
  }
  stepper1.run();
}

Hi,
If you use a stepper, you will need to have two limit switches, one each at the end of the stepper sweep.
These switches will also give you an indication of the position of the valve shaft.
Limit switches will also let you know where your stepper is when powered up, you would check to see if the HOME limit is activated, if not HOME the stepper until its limit is activated.
This way your code knows what position the stepper is in, before trying to control the valve.

Those 5V steppers are not very powerful, have you checked that it can turn the valve?

Tom.... :smiley: :+1: :coffee: :australia:

To review.
You have a stepper
You have a valve.
You have a stepper driver
You can rotate the stepper 90 degrees and back to 0

You followed the tutorials for how to use a stepper and make it work.

You want to move about 2000 steps when set on quarter step. To rotate 90 degrees

You want a single LED to turn on at 0.
A second at about 9 degrees or 10% Or 200 steps.
A 3rd LED to light after rotating 19 degrees or 20% or 400 steps.
And so on

You want us to wtite a sketch for you to turn the LEDs off and on?

tomgeorge might be right.
For a lightweight value this is a good type of motor to run a value on and off. It has slow speed and reasonable torque for a 5V motor. But tomgeorge is right, if it is a heavy value it won't.

Note that, for this stepper/gearbox there is not a precise number of pulses to turn it exactly 90 degrees. The gearing is not even, so (when I tested one) it took 2037.5 (yes "point 5") pulses to turn 360 degrees.
So, if you are turning it 90 degrees one way, and then 90 degrees back it'll probably be OK. But if you are making full turns, you will need those limit switchs or something so you can determine a set position.

Note Also that the 12V version of that motor has noticeably more torque - just in case the 5V struggles to turn your valve.