Hey folks. I have a very simple project going. I'm using a stepper motor to pull a cable that actuates a small lever to press a mechanical button on an aerosol can. basic operation is: push a button, stepper actuates and then waits a second to check the button status again.
I'm using an adafruit motor shield. Using Stepper Motors | Adafruit Motor Shield V2 | Adafruit Learning System
with an Uno. The uno is on a 12v wall wart, the adafruit has it's own 12v wall power. I do not have the jumper attached, so the boards are each on their own power.
I have this motor working: Stepper motor - NEMA-17 size - 200 steps/rev, 12V 350mA : ID 324 : $14.00 : Adafruit Industries, Unique & fun DIY electronics and kits
but the torque is not strong enough.
This is the code:
/*
This is a test sketch for the Adafruit assembled Motor Shield for Arduino v2
It won't work with v1.x motor shields! Only for the v2's with built in PWM
control
For use with the Adafruit Motor Shield v2
----> http://www.adafruit.com/products/1438
*/
#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 *myMotor = AFMS.getStepper(200, 1);
const int ledPin = 13; // the number of the LED pin
const int buttonPin = 2; // the number of the pushbutton pin
// variables will change:
int buttonState = 0; // variable for reading the pushbutton status
void setup() {
//Serial.begin(9600); // set up Serial library at 9600 bps
//Serial.println("Stepper test!");
AFMS.begin(); // create with the default frequency 1.6KHz
//AFMS.begin(1000); // OR with a different frequency, say 1KHz
myMotor->setSpeed(70); // 10 rpm
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// initialize the pushbutton pin as an input:
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
// check if the pushbutton is pressed. If it is, the buttonState is HIGH:
if (buttonState == HIGH) {
// turn LED on:
digitalWrite(ledPin, HIGH);
myMotor->step(100, FORWARD, SINGLE);
myMotor->step(100, BACKWARD, SINGLE);
delay(1000);
} else {
// turn LED off:
digitalWrite(ledPin, LOW);
//do nothing with motor
}
}
works great. push the button, servo actuates. Just not strong enough to pull the lever, so I got this motor: 12V, 1.7A, 416 oz-in Geared Bipolar Stepper Motor - RobotShop
but it doesn't work. Same code, same wiring. Motor is rated at 12v and 1.2 amps, adapter is 12v and 1a. I'm assuming the amps are the problem.
What currently happens is, everything lights up correctly once the board is plugged in. then, when you press the button, the motor moves a little bit, the power light starts blinking very, very slowly, and the motor moves a tiny, tiny bit forever until I reset the arduino or unplug it.
help? I'm shooting in the dark here and have no one locally to help. can't find the answers on the interwebs because i dont know what to search for.
thanks.