ok so im just getting into using an arduino to control a stepper motor and im flustered.
i have a nema 17 stepper motor and a TMC2209 along with 6 switches. (4 pole, 3 way rotary selectors technically) and a "trigger" button i'd like to get control over the stepper via the switches in this sort of setup
speed -
switch 1 high = slow
switch 2 high = medium
switch 3 high = fast
then the same but for rotations (so i know this is done via step count)
switch 1 high = 2 rotations
switch 2 high = 3 rotations
switch 3 high = 4 rotations
i will be using 4 pole 3 way rotary selectors for this, but honestly, other than the basic examples i found online for setting up the pinouts of the 2209 im entirely lost where to begin.
can someone direct me in the starting direction using lamens terms?
this is what ive been able to get as far as setup and definitions go but
#define EN_PIN 9
#define STEP_PIN 10
#define DIR_PIN 11
const int lowspeed = 3;
const int mediumspeed = 4;
const int highspeed = 5;
const int twoturns = 6;
const int threeturns =7;
const int fourturns = 8;
const int trigger = 12;
void setup(){
pinMode(EN_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
digitalWrite(EN_PIN, LOW);
digitalWrite(DIR_PIN, LOW);
pinMode (lowspeed, INPUT);
pinMode (mediumspeed, INPUT);
pinMode (highspeed, INPUT);
pinMode (twoturns, INPUT);
pinMode (threeturns, INPUT);
pinMode (fourturns, INPUT);
pinMode (trigger, INPUT);
}
void loop(){
digitalWrite(DIR_PIN, LOW); //only need it to turn in one direction
if (trigger = HIGH){ //insert switch variables and commands here?
if (lowspeed = HIGH){ //set speed to X steps per second
}
else();
}
if (mediumspeed = HIGH){
}
else();
if(highspeed = HIGH){
}
else();
}
if (twoturns=HIGH){ //set steps to turn here?
}
else(); //do nothing
}
its not much, but its the start i guess, i just dont know how to construct the remaining if/else arguements to check the switch possitions and make those take the correct steps, nor am i sure how to setup the stepper motor in code so 2 turns = # steps and low speed = #steps per second.
hope that all made sense and you understand where i need the help.
considering this is my very first venture im rather proud i made it this far as i THINK the code so far is good lol