aboutsummaryrefslogtreecommitdiff
path: root/Arduino2024
diff options
context:
space:
mode:
Diffstat (limited to 'Arduino2024')
-rw-r--r--Arduino2024/Arduino2024.ino33
-rw-r--r--Arduino2024/NewMotor/NewMotor.ino99
2 files changed, 0 insertions, 132 deletions
diff --git a/Arduino2024/Arduino2024.ino b/Arduino2024/Arduino2024.ino
deleted file mode 100644
index 3e48358..0000000
--- a/Arduino2024/Arduino2024.ino
+++ /dev/null
@@ -1,33 +0,0 @@
-
-/*
- simple rotation of the motor
- the gear ration on the carousel is
- 7/40 and there is 10 slots to rotate between
-
-
-
-*/
-
-
-//define Pins
-#define PulPin 7
-#define dirPin 6
-int pd = 500;
-
-void setup() {
-
- pinMode(PulPin, OUTPUT);
- pinMode(dirPin, OUTPUT);
-
-}
-
-void loop() {
-
- digitalWrite(dirPin, HIGH);
- digitalWrite(PulPin, HIGH);
- delayMicroseconds(pd);
- digitalWrite(PulPin, LOW);
- delayMicroseconds(pd);
-
-
-}
diff --git a/Arduino2024/NewMotor/NewMotor.ino b/Arduino2024/NewMotor/NewMotor.ino
deleted file mode 100644
index b943185..0000000
--- a/Arduino2024/NewMotor/NewMotor.ino
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <MobaTools.h>
-
-const byte stepPin = 12; // PWM send many pulses to drive carosel
-const byte dirPin = 13; // Direction
- //const byte enablePin = 8;
-
-
-//steps per position
-int stepsToMove = 828; // Magic number
-unsigned long stepDelay = 1000; // milliseconds
-
-MoToStepper stepper( 400, STEPDIR );
-
-void setup()
-{
- Serial.begin(115200);
- Serial.println("ESP32 is ready");
-
- pinMode(13, OUTPUT);
-
- stepper.attach( stepPin, dirPin );
- stepper.setSpeedSteps(20000); // = 75 steps/second (steps in 10 seconds)
- stepper.setRampLen(500);
- stepper.setZero();
- pinMode(2,OUTPUT);
-}
-
-void loop()
-{
- if (Serial.available()>0){
- //digitalWrite(2, HIGH);
- String command_string = Serial.readStringUntil('\n'); //read communication until next line
- Serial.println("OK");
- command_string.trim();//removes any spaces before and after
-
- int firstSpaceIndex = command_string.indexOf(' ');//find the first space
- if(firstSpaceIndex != -1)
- {
- String commandName = command_string.substring(0, firstSpaceIndex);
-
- int secondSpaceIndex = command_string.indexOf(' ', firstSpaceIndex + 1);
- if(secondSpaceIndex != -1){
- int pumpNumber = command_string.substring(firstSpaceIndex + 1, secondSpaceIndex).toInt();
- int pumpValue = command_string.substring(secondSpaceIndex + 1).toInt();
-
- if(commandName == "Pump")
- {
- Pump(pumpNumber, pumpValue);
- }
- } else{
- String secondValue = command_string.substring(firstSpaceIndex + 1, command_string.length() + 1);
- Serial.println("Second value: \"" + secondValue + "\"");
-
- if(commandName == "Position"){
- GoToPosition(secondValue.toInt() * stepsToMove);
- }
- if(commandName == "LED"){
- bool led_on = secondValue == "1";
- Serial.println("LED " + led_on ? "on" : "off");
- digitalWrite(2, led_on ? HIGH: LOW);
- }
- }
- }
- }
- //digitalWrite(2, HIGH);
- delay(1000);
- //digitalWrite(2, LOW);
-}
-
-void GoToPosition(int value){
- //execute code
- Serial.print("Position command executed with value: ");
- Serial.println(value);
- stepper.moveTo(value);
-}
-void Pump(int number,int value){
- //Execute code
- Serial.print("Pump: ");
- Serial.println(number);
- Serial.println(" value: ");
- Serial.println(value);
-
-}
-/*
-stepper.moveTo(pos9);
- while(stepper.distanceToGo() > 0);
- Serial.write("current position :");
- delay(stepDelay);
- stepper.moveTo(pos2);
- while(stepper.distanceToGo() > 0);
- delay(stepDelay);
- stepper.moveTo(pos5);
- while(stepper.distanceToGo() > 0);
- delay(stepDelay);
- stepper.moveTo(pos3);
- while(stepper.distanceToGo() > 0);
-
- delay(stepDelay);
-*/