I got an Arduino UNO a while ago and found out how to do things. I learnt to code a bit and I was trying to make 2 buttons control a stepper motor to make it go one way or the other, I thought I did it but alas it will only go clockwise when I plug it in. here is the code.
#include <Stepper.h>
const int stepsPerRevolution = 200;
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);
void setup() {
myStepper.setSpeed(60);
Serial.begin(9600);
pinMode(0, INPUT);
pinMode(1, INPUT);
}
void loop() {
if (digitalRead(0) == HIGH)
{
Serial.println("clockwise");
myStepper.step(stepsPerRevolution);
}
if (digitalRead(1) == HIGH)
{
Serial.println("counterclockwise");
myStepper.step(-stepsPerRevolution);
}
}
other info:
button, OUTPUT 5V, INPUT 0
button, OUTPUT 5V, INPUT 1
step motor OUTPUT 5V, INPUT GND, 1N1 8, 1N2 9, 1N3 10 1N4, 11
Moderator edit:
</mark> <mark>[code]</mark> <mark>
</mark> <mark>[/code]</mark> <mark>
tags added.