laser-fototransistor-stepmotor-arduino

Hello,

I'm working on transmision belt. Stepp motor drives t-belt to sensors, after detekcion items on sensor, belt need to stop moving (stepp motor stop moving).

Im using Laser and fototransistor to detekcion items, L298n module to control nema 14 motor.

here is code

#include <AccelStepper.h>

AccelStepper stepper2(AccelStepper::FULL4WIRE, 8, 9, 10, 11);
bool inputWasLow=true;
#define senzor 7

void setup()
{

  Serial.begin(9600);
  pinMode(senzor,INPUT);
  stepper2.setMaxSpeed(100);
  stepper2.setAcceleration(50);
  stepper2.runSpeed();
}

void loop()
{
  if(digitalRead(senzor)==1)
{
  inputWasLow=true;
   stepper2.runSpeed();
}
if(digitalRead(senzor)==0)
{
  if(inputWasLow)
{
  inputWasLow==false;
stepper2.stop();
delay(1000);
}
stepper2.runSpeed();
}}

problem: motor don't move

connection sheme - LASER- GND -5v
FOTOTRANSISTOR - 5v- 100oHM RESISTOR -INPUT 7
RESISTOR- FOTOTRANSISTOR-GND

Does the motor work if you remove the code for the sensor?

Post a wiring diagram (can be hand-drawn)!

And format your code. In formatted code you never see two curly braces on one line and code in the same block has the same indentation.

The L289 works for only low current stepping motors. The DRV8825 works much better for low and medium current (up to 1.5 Ampere/winding) motors.

Please post a link to the exact stepping motor you are using, and give the voltage and current specification of the motor power supply.