diff options
| author | Carlos Maiolino <[email protected]> | 2025-07-10 22:55:07 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-07-10 22:56:55 +0200 |
| commit | d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 (patch) | |
| tree | 267474fcc77cf20b428f6f4c7f768ca09f4cfe0e /Arduino/andrei_guindaste | |
| parent | 869e68986aa8f69af6e7842260a68d1e5c6f796f (diff) | |
Add new code
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'Arduino/andrei_guindaste')
| -rw-r--r-- | Arduino/andrei_guindaste/guindaste_engine/guindaste_engine.ino | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/Arduino/andrei_guindaste/guindaste_engine/guindaste_engine.ino b/Arduino/andrei_guindaste/guindaste_engine/guindaste_engine.ino new file mode 100644 index 0000000..494ab3c --- /dev/null +++ b/Arduino/andrei_guindaste/guindaste_engine/guindaste_engine.ino @@ -0,0 +1,47 @@ +#include <AccelStepper.h> + +#define FULLSTEP 4 +#define STEP_PER_REVOLUTION 2038 + +#define BTN_UP 51 +#define BTN_DOWN 31 + +AccelStepper stepper(FULLSTEP, 11, 9, 10, 8); +void setup() { + // put your setup code here, to run once: + Serial.begin(9600); + stepper.setMaxSpeed(1000.0); + //stepper.setAcceleration(50.0); + stepper.setSpeed(200); + //stepper.setCurrentPosition(0); + //stepper.moveTo(STEP_PER_REVOLUTION); + + //pinMode(BTN_UP, INPUT_PULLUP); + pinMode(BTN_UP, INPUT); + pinMode(BTN_DOWN, INPUT); +} + +void loop() { + // put your main code here, to run repeatedly: + // if (stepper.distanceToGo() == 0) + // stepper.moveTo(-stepper.currentPosition()); + + // stepper.run(); + // Serial.print(F("Current Position: ")); + //Serial.println(stepper.currentPosition()); + stepper.setMaxSpeed(1000); + + if(digitalRead(BTN_UP)) + stepper.setSpeed(-600); + else if(digitalRead(BTN_DOWN)) + stepper.setSpeed(600); + + + while (!digitalRead(BTN_UP) || !digitalRead(BTN_DOWN)) { + stepper.runSpeed(); + } + stepper.stop(); + Serial.println(digitalRead(BTN_UP)); + + + } |
