I need to write a code wherein NEMA 17 stepper motor should stop, if IR sensor detect 5 objects. I am using A4988 stepper motor driver...Pls help... I am new in Arduino coding
I moved your topic to an appropriate forum category @atuljain89.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
- Make a list of devices in your project:
- stepper motor
- a driver board for the stepper motor
- a power supply for the stepper motor
- an infrared object sensor
- an Arduino
- power supply for Arduino
- more?
- Make a drawing of your project labeling how all these devices will be connected.
- Download the specifications page (datasheet) of each device.
- The most important part of this project is the motor driver. You must set your A4988 current limit to match your stepper motor to run without damage. Here is an example video of setting the current limit of a DRV8825, which has the code to use for testing your driver and stepper.
https://www.youtube.com/watch?v=89BHS9hfSUk - Code - start with writing a sketch for each device on its own until they work, then combine the sketches.
Do you mean 5 at the same time or 5 at different times?
Hi @atuljain89,
welcome to the arduino-forum.
I'm pretty sure that you agree and will follow the way how to solve your problem mimimum 200 minutes faster.
This requires to invest 20 minutes of your precious time to read how to speedup solving your problems.
Directly after registering you got presented informations how to speed up solving your problem.
You should really read it.
best regards Stefan
Yes Stefan, I understand that... I would follow the forum guidelines in future posts
Dear Jim, I mean that motor is running continuously and IR is counting the objects... Once 5 objects passed/count by the IR then only motor should stop.
So what hardware do you have?
One of these very important things is what hardware you really have.
Some stepper-drivers use 4 IO-pins, some use two IO-pins
What kind of IR-sensor is this?
What is the distance between this IR-sensor and the objects?
What kind of signal does your IR-sensor have?
or in other words is it:
- a logic TTL-level output ?
- open-collector?
- relay-contact?
What is the supply-voltage of the IR-sensor?
As you can see from all these questions you really need to read the tutorial and then provide all these detail-information.
The microcontroller-world is NOT super-standardised like USB-devices.
You have to take care of more details than just
"does the plug fit into the socket?"
For driving the stepper-motor I recommend that you use the MobaTools-Library which can be installed from the library-manager of the Arduino-IDE.
for driving stepper-motors: MobaTools.h
The MobaTools are much easier to use than stepper.h or AccelStepper.h
The reason is execute a single comand
myStepper.rotate(1);
and the stepper-motor will run until you execute
myStepper.stop();
with stepper.h or accellstepper.h you have to code a loop that must run very fast to keep the stepper-motor rotating smoothly.
Needs much more programming-experience to work with stepper.h or accelStepper.h
than for using the MobaTools.h-library
So I'm looking forward to your detail-posting
best regards Stefan
Assembly line style...
@xfpd You made my day but let's please try to help @atuljain89
@atuljain89
This is a good tuorial on how to hook up the driver with some example code.
See if ou can first make the stepper work, then we will go on to making the IR work.
Post your drawing here... something like this...
What is your object sensor:
- a "module" (HW-201, transmitter and receiver on a board) capable of digital or analog output, or
- a pair of TX/RX IR LEDs that will need other discrete components and calibrating
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.