Hi, I am new for arduino, I doing the conveyor project with programming code as per below:-
#include <Wire.h>
#include <Adafruit_MotorShield.h>
// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield();
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61);
// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *myMotor1 = AFMS.getStepper(200, 1);
Adafruit_StepperMotor *myMotor2 = AFMS.getStepper(200, 2);
void setup() {
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
myMotor1->setSpeed(100); // rpm
myMotor2->setSpeed(100); // rpm
pinMode(2, INPUT); // CV present snesor
digitalWrite(2,HIGH);
pinMode(4,INPUT);//CV stop sensor
digitalWrite(4,HIGH);
}
void loop() {
if(digitalRead(2) == LOW && digitalRead(4) == HIGH){
digitalWrite(2,LOW);
myMotor1->step(200, FORWARD, DOUBLE);
if(digitalRead(4)==LOW){
digitalWrite(2,HIGH);
}
when i put the box on conveyor, the present sensor detect and conveyor is continuous running until stop sensor detect.
the problem is when i put the box, the present sensor detect but i take out the box from conveyor, the conveyor is always running.
the conveyor image as per attachment
any idea to program the conveyor to solve the problem.
thanks