I am new to both Arduino and Programming. I want to develop a stepper motor application which involves 360 degree forward and backward motion. I am using adafruit stepper motor driver for this. Till now I have managed to move the stepper motor in clockwise and anticlockwise direction.
I want stepper motor to start from specific point whenever the process (Arduino) starts. For this I tried to hook up a IR Speed Motion Sensor (got it from friend. It gives ttl output, when circuit breaks it shows value around 800 when circuit closes its around 45) but I am not able to use as a switch for stepper motor.
I can understand this might be a silly question and my sincere apologies for that. If someone can help me or suggest me some other alternative which can used as a switch for stepper motor.
Thank you
Following is the code.
#include <AFMotor.h>
AF_Stepper Stepper(200,2);
int posPin=A0;
int readValue;
int i=1;
I want stepper motor to start from specific point whenever the process (Arduino) starts.
Do you mean you want to set the shaft of the stepper to a specific angle at start?
is there something moving connected to the motor (i would assume so)? typically you would use a limit switch and turn your motor in one direction until that switch gets activated by your mobile part hitting the switch. then you know where you are, at a reference point and you can count steps to the "home" position
A speed sensor, as its name implies, is for measuring speed not position
Look for limit switch onyour favorite store - they look somewhat like this with a contact switch that might be different based on the needs of your moving platform
Do you have an IR switch or some kind of speed sensor ? If it's a switch it can work.
Does your component look like a small wheel with holes and a circuit with a "U" shaped component with IR emitteron one side and receiver on the other?
If you have something with the U shape then as long as your motorized part can have something coming inside the U to block the IR then you can use it to detect position
I had powered it correctly. I tried to print numbers when there is obstacle in the switch (circuit break), it was working with all loops. I was reading the input from analog pin. Following is the code.
#include <AFMotor.h>
AF_Stepper Stepper(200,2);
int posPin=A0;
int readValue;
int i=0, j=0;
Take your component, wire it (power and ground) correctly and attach the digital pin to D3 and the analog pin to A0 (if it offers both Output)
Write a very small piece of code where in setup() you open the serial connection, declare the pins as input and in the loop just read the values (so digitalRead and analogRead) and print them.
Now take a piece of cardboard and stick it and remove it from the middle of the U shaped element and see how the values change in the console.
Once you get this working andunderstand how the values change, then you can move to the next stage of integrating that with your motor