Need a little help with some pure basic code (I bloody hate code)
Trying to set a stepper motor up to be controlled by a couple of buttons, one to start the motor to step continuous (with a delay), and another button to turn the motor just once.
Iv written the code for the motor:
#include <Stepper.h>
#define motorSteps 200 // change this depending on the number of steps
// per revolution of your motor
#define motorPin1 8
#define motorPin2 9
// initialize of the Stepper library:
Stepper myStepper(motorSteps, motorPin1,motorPin2);
void setup() {
// set the motor speed at 60 RPMS:
myStepper.setSpeed(60);
}
void loop() {
// Step forward 100 steps:
myStepper.step(49);
delay(500);
}
But How do i go about setting it up so it will wait for a input from a button?
I guess I have to set the buttons with
const int buttonPin1 = 1;
const int buttonPin2 = 2;
????
And how would I denote two "buttonStates" for setting if (buttonState == HIGH/ == LOW)
I know this is really basic stuff, but even the basics when it comes to code escapes me!
There are a number of button tutorials on the Arduino site that might help you get started. You can start on the Tutorial page, and look in the Digital I/O section.
Thanks AlphaBeta will go test out the coe tonight......but I make sense now you have laid it out in the right format, and Grumpy_Mike comments......thanks guys