HELP for the Arduino Lesson 16. Stepper Motors

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

The ground and que 5V of the Arduino are connected on the breadboard (the blue and red line). Then I plugged the receiver directly with this 2 lines.

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

What happens if you manually pull pin 2 high (use a jumper from pin 2 t0 5v).

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

Nothing

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

Your code is still waiting for serial input. Remove that code if you don't intend to use it.

Code: Select all

  // this line is for Leonardo's, it delays the serial interface
  // until the terminal window is opened
  while (!Serial);

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

Yes I tried, but it's still the same.

I wonder if the D0 and D1 are available for this remote control.
I just tried to wire 4 leds to D0 D1 D2 and D3, and the remote seems to control only D3 (for A bottom), and D2 (for B buttom).
So I tried again with D2 and D3 but it is the same thing. The motor doesn't want to react.

Code: Select all

#include <Stepper.h>
int stepsPerRevolution = 768;

int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
Stepper motor(768, in1Pin, in2Pin, in3Pin, in4Pin);  
 
void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  
  motor.setSpeed(10);
}
 
void loop()
{
  if (digitalRead(2) == HIGH)
  {
  
    motor.step(stepsPerRevolution/2);
  }
  else if ( digitalRead(3) == HIGH)
  {
    motor.step(-stepsPerRevolution/2);
  }
}

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

But you were able to get the motor to turn in an earlier test. Post the code you used for that test.

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

It works with the tutorial n°16

Code: Select all

/*
Adafruit Arduino - Lesson 16. Stepper
*/
 
#include <Stepper.h>
 
int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
Stepper motor(512, in1Pin, in2Pin, in3Pin, in4Pin);  
 
void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
 
  // this line is for Leonardo's, it delays the serial interface
  // until the terminal window is opened
  while (!Serial);
  
  Serial.begin(9600);
  motor.setSpeed(10);
}
 
void loop()
{
  if (Serial.available())
  {
    int steps = Serial.parseInt();
    motor.step(steps);
  }
}

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

Then I see no reason why your motor would not move if you manually jumper Arduino pin 2 (or pin 3) to 5v with this code.

Code: Select all

#include <Stepper.h>
int stepsPerRevolution = 768;

int in1Pin = 12;
int in2Pin = 11;
int in3Pin = 10;
int in4Pin = 9;
 
Stepper motor(768, in1Pin, in2Pin, in3Pin, in4Pin);  
 
void setup()
{
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(in3Pin, OUTPUT);
  pinMode(in4Pin, OUTPUT);
  
  motor.setSpeed(10);
}
 
void loop()
{
  if (digitalRead(2) == HIGH)
  {
  
    motor.step(stepsPerRevolution/2);
  }
  else if ( digitalRead(3) == HIGH)
  {
    motor.step(-stepsPerRevolution/2);
  }
}

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

Indeed, when I manually wire pin2 to 5v, the motor start to turn. But it turns infinitely clockwise

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

Indeed, when I manually wire pin2 to 5v, the motor start to turn. But it turns infinitely clockwise
Let's solve one problem at a time here.

So the code works if Pin 2 goes high. And your LED experiments show that the receiver is active on channels D2 and D3. What happens if you connect D2 and D3 to Arduino pins 2 and 3?

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

Nothing... that's why I don't understand where is the problem... :/
However the code seems to be logic

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

Can you measure the voltage of the signal output from your receiver's D2 and D3 when they are active?

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

I will be able to do that tomorow afternoon. I keep you in touch.

Thanks a lot !

User avatar
kev06
 
Posts: 30
Joined: Thu Aug 15, 2013 6:47 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by kev06 »

4.7v when I individually press A and B on D2 and D3


I think it could be easier if I just use 1 botton. First press and the motor turn 180 clockwise. And then second press the motor turn 180 in the same way ?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: HELP for the Arduino Lesson 16. Stepper Motors

Post by adafruit_support_bill »

4.7v when I individually press A and B on D2 and D3
That should be enough to register as a logic HIGH. It should work the same as your manual jumper test before.
Was that measurement taken with D2 and D3 connected to the Arduino pins also?
I think it could be easier if I just use 1 botton. First press and the motor turn 180 clockwise. And then second press the motor turn 180 in the same way ?
If we can get 1 button to work, we should be able to get 2 to work also.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”