Hi! I'm trying to have a stepper motor move steps according to keypad input. I have a program written and the keypad is read but the motor never moves can anyone help?
JD.ino (994 Bytes)
Hi! I'm trying to have a stepper motor move steps according to keypad input. I have a program written and the keypad is read but the motor never moves can anyone help?
JD.ino (994 Bytes)
OP's code posted where people can see it and he might actually get help. Why doesn't anyone read the How to use this forum thread?
// Simple use of keypad, stepper
#include <Keypad.h>
#include <Wire.h>
#include <AFMotor.h>
AF_Stepper motor(200, 2);
char customKey;
const byte ROWS = 4;
const byte COLS = 4;
int x = 0;
char keys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2,3,4,5}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {6,7,8,9}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
motor.setSpeed(10); // 10 rpm
}
void loop(){
x=0;
customKey = customKeypad.getKey();
if(customKey) {
Serial.println(customKey);
int keyInt = (customKey- '0');
Serial.println(keyInt);
while(x<100){
motor.step(1,FORWARD,DOUBLE);
x++;
Serial.println(x);
}
}
}
Can you show how you have this wired up? What do you see printed?
.
@hannahgregson, can you get the motor to work with a simple program without any keypad input? If not that should be your first goal.
Please post a link to the datasheet for your stepper motor and for your stepper motor driver.
What stepper motor power supply are you using (volts and amps)?