It appears I am using 10k ohm resistors, my mistake.
Here is my code. note like my title says, I'm a newbie.
tried my best to comment / formatted correctly.
#include <AccelStepper.h>
const byte stepPin1 = 8;
const byte stepPin2 = 9;
const byte stepPin3 = 10;
const byte stepPin4 = 11;
const byte buttonPin = 2;
const byte limitTop = 4;
const byte limitBottom = 5;
int Direction = HIGH;
const int topSpeed = 10000; // Set stepper max speed
boolean Initialized = false;
boolean ToggleSwitch = false;
boolean limitTpressed = false;
boolean limitBpressed = false;
boolean inMotion = false;
AccelStepper myStepper(AccelStepper::FULL4WIRE, stepPin1, stepPin2, stepPin3, stepPin4);
void setup ()
{
pinMode (limitTop, INPUT);
pinMode (limitBottom, INPUT);
pinMode (buttonPin, INPUT);
myStepper.setMinPulseWidth(20);
myStepper.setMaxSpeed(topSpeed);
}
void loop ()
{
if (!Initialized) { // System turned on, move to top and initialize
movetoTop();
}
if (Initialized) { // If it's initialized, proceed
if (!ToggleSwitch) { // If the Momentary button hasn't been pressed, check it,
ToggleCheck(); // sets Momentary button(ToggleSwitch) value.
}
if ((inMotion) && (Direction == HIGH)) {
movetoTop();
}
if ((inMotion) && (Direction == LOW)) {
movetoBottom();
} //if its not inMotion do nothing.
}
}
void ToggleCheck()
{
int val = digitalRead(buttonPin);
if (val == LOW) {
ToggleSwitch = true;
inMotion = true;
Direction = (Direction == HIGH) ? LOW : HIGH; //Toggles which direction it has been moved when button is pressed
}
if (val == HIGH) {
ToggleSwitch = false;
}
}
void movetoTop()
{
int val = digitalRead(limitTop); //get top limit switch value
if (val == HIGH) {
limitTpressed = true;
}
if (val == LOW) {
limitTpressed = false;
}
if (!limitTpressed) { //if the top limit switch isn't pressed, move it up.
inMotion = true;
myStepper.moveTo(400000); //uses acceleration so motor doesnt stall
myStepper.run();
}
if (limitTpressed) { //halt movement
myStepper.setCurrentPosition(0);
Initialized = true;
inMotion = false;
ToggleSwitch = false;
Direction = HIGH;
}
}
void movetoBottom()
{
int val = digitalRead(limitBottom); //get bottom limit switch value
if (val == HIGH) {
limitBpressed = true;
}
if (val == LOW) {
limitBpressed = false;
}
if (!limitBpressed) { //if the bottom limit switch isn't pressed, move it down at full speed.
inMotion = true;
myStepper.setSpeed(-topSpeed); // Sets top speed to go in reverse (Move down)
myStepper.runSpeed();
}
if (limitBpressed) { //halt movement
myStepper.setCurrentPosition(0);
inMotion = false;
Direction = LOW;
ToggleSwitch = false;
}
}