I would like to be able to have 3 Momentary switches that when pressed will let me be able to select from 3 speeds or 3 settings. Here is my basic sketch without any switches.
Any advice will be appreciated?
TIA
/* Example sketch to control a stepper motor with TB6600 stepper motor driver, AccelStepper library and Arduino: acceleration and deceleration. More info: https://www.makerguides.com */
---------------------------------------------------------------------------------------------------------------
Replies:
#include <AccelStepper.h>
#define dirPin 2
#define stepPin 3
#define motorInterfaceType 1
const int buttonPin1 = 8;
const int buttonPin2 = 9;
const int buttonPin3 = 10;
int buttonState1 = 0;
int buttonState2 = 0;
int buttonState3 = 0;
void setup () {
pinMode(buttonPin1, INPUT);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
}
void loop () {
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
buttonState3= digitalRead(buttonPin3);
if (buttonState1 == 1) {
stepper.setMaxSpeed(300);
stepper.setAcceleration(500);
}
if (buttonState2 == 1) {
stepper.setMaxSpeed(600);
stepper.setAcceleration(500);
}
if (buttonState3 == 1) {
stepper.setMaxSpeed(1000);
stepper.setAcceleration(500);
}
}
//in void setup () not finish
-------------------------------
How do I upload images to share with you all? I have a Nema 34 with microstep driver and powersupply. Things I would like to share if possible?
Make the best of today.
How do I upload images to share with you all?
Click the Attach Files option on the bottom bar where you type your posts.
To make your programs easier to read,
https://forum.dronebotworkshop.com/question-suggestion/sticky-post-for-editing/#post-4939
Make the best of today.
Make the best of today.
Make the best of today.
stepper.setMaxSpeed(300);
Reason I ask is "setMaxSpeed" is not a defined variable. It's assuming there is a MaxSpeed.
Make the best of today.
I think that some of the methods in that library are 'float' types.
https://www.airspayce.com/mikem/arduino/AccelStepper/classAccelStepper.html
You may want to adjust based on that.
Make the best of today.
Have Fun,
Joe Lyddon
www.woodworkstuff.net