HELP for the Arduino Lesson 16. Stepper Motors
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
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.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
What happens if you manually pull pin 2 high (use a jumper from pin 2 t0 5v).
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
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);
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
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.
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);
}
}
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
But you were able to get the motor to turn in an earlier test. Post the code you used for that test.
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
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);
}
}
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
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);
}
}
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
Indeed, when I manually wire pin2 to 5v, the motor start to turn. But it turns infinitely clockwise
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
Let's solve one problem at a time here.Indeed, when I manually wire pin2 to 5v, the motor start to turn. But it turns infinitely clockwise
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?
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
Nothing... that's why I don't understand where is the problem... :/
However the code seems to be logic
However the code seems to be logic
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
Can you measure the voltage of the signal output from your receiver's D2 and D3 when they are active?
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
I will be able to do that tomorow afternoon. I keep you in touch.
Thanks a lot !
Thanks a lot !
- kev06
- Posts: 30
- Joined: Thu Aug 15, 2013 6:47 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
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 ?
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 ?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: HELP for the Arduino Lesson 16. Stepper Motors
That should be enough to register as a logic HIGH. It should work the same as your manual jumper test before.4.7v when I individually press A and B on D2 and D3
Was that measurement taken with D2 and D3 connected to the Arduino pins also?
If we can get 1 button to work, we should be able to get 2 to work 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 ?
Please be positive and constructive with your questions and comments.