aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSjory <Mgj32000@gmail.com>2023-10-19 23:05:03 +0200
committerSjory <Mgj32000@gmail.com>2023-10-19 23:05:03 +0200
commit42786e7dfd912225c53a232bc95cad3842276b55 (patch)
tree3df22fe133c5c42c2371ad7a62d871cc6095756b
parent57432f32cc62590688c4789ce17557c3f259b065 (diff)
Rough code for ESP32
made some methods for activating the pumps and motor carousel and the linear actuator for doesing alcohol. roughly still need to implment the MQTT Client to listen for messages (unless using another method for comunication between raspberry pi and ESP32)
-rw-r--r--Drinks maskine.drawio (1).pngbin112074 -> 75072 bytes
-rw-r--r--ESP32Test/CodeForESP32/CodeForESP32.ino87
-rw-r--r--ESP32Test/ESP32Test.ino22
-rw-r--r--ESP32Test/arduinoTest/arduinoTest.ino38
4 files changed, 87 insertions, 60 deletions
diff --git a/Drinks maskine.drawio (1).png b/Drinks maskine.drawio (1).png
index 4c5bbdf..64fd2a8 100644
--- a/Drinks maskine.drawio (1).png
+++ b/Drinks maskine.drawio (1).png
Binary files differ
diff --git a/ESP32Test/CodeForESP32/CodeForESP32.ino b/ESP32Test/CodeForESP32/CodeForESP32.ino
new file mode 100644
index 0000000..caf6fac
--- /dev/null
+++ b/ESP32Test/CodeForESP32/CodeForESP32.ino
@@ -0,0 +1,87 @@
+#include <Stepper.h>
+
+#define STEPS 200
+#define motorInterfaceType 1
+
+//------stepper motor for carousel----------
+Stepper stepper(STEPS, 2, 3); // Pin 2 connected to DIRECTION & Pin 3 connected to STEP Pin of Driver
+int stepperSleepPin = 0;
+int stepperCounter = 0;
+
+//------linear actuator for doseing-----------
+int doesActivatePin = 0;
+int doesDeactivatePin = 0;
+
+
+void setup() {
+ stepper.setSpeed(1000);
+ pinMode(stepperSleepPin, OUTPUT);
+ //Sleeps motor to stop overheating
+ digitalWrite(stepperSleepPin, HIGH);
+
+ pinMode(doesActivatePin, OUTPUT);
+ pinMode(doesDeactivatePin, OUTPUT);
+}
+
+void loop() {
+
+ //-------Wait for MQTT BROKER message--------//
+
+}
+
+//-------------Dosing valve activation----------------//
+void doesAlcohol(){
+ digitalWrite(doesActivatePin, HIGH);
+ delay(5000);
+ digitalWrite(doesActivatePin, LOW);
+ digitalWrite(doesDeactivatePin, HIGH);
+ delay(2000);
+ digitalWrite(doesDeactivatePin, LOW);
+
+
+ //Send message for done doesing
+}
+
+
+//-------------Carousel activation----------------//
+
+void runCarousel(int steps){
+ //Wakes up motor to run
+ digitalWrite(stepperSleepPin, LOW);
+
+ //---------Add acceleration to save motor from inertia from the carousel--------//
+
+ stepper.step(steps);
+ stepperCounter = stepperCounter + steps;
+
+ //Sleeps motor to stop overheating
+ digitalWrite(stepperSleepPin, HIGH);
+
+ //Send message for done runing
+}
+
+
+//-------------Pumps activation----------------//
+
+void activatePump(int pump, int time){
+
+ pinMode(pump, OUTPUT);
+ digitalWrite(pump, HIGH);
+ delay(time);
+ digitalWrite(pump, LOW);
+ //Send message for done pumping
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ESP32Test/ESP32Test.ino b/ESP32Test/ESP32Test.ino
deleted file mode 100644
index e1cb1c7..0000000
--- a/ESP32Test/ESP32Test.ino
+++ /dev/null
@@ -1,22 +0,0 @@
-#include <Arduino.h>
-#include <ESP32Servo.h>
-
-Servo myServo;
-int servoPin = 12;
-
-void setup() {
- //myServo.attach(servoPin);
- //myServo.write(0);
- Serial.begin(115200);
- pinMode(2, OUTPUT);
-}
-
-void loop() {
- digitalWrite(13, HIGH);
- Serial.write(High);
- delay(1000);
- digitalWrite(13, LOW);
-
- Serial.write("Low");
- delay(1000);
-} \ No newline at end of file
diff --git a/ESP32Test/arduinoTest/arduinoTest.ino b/ESP32Test/arduinoTest/arduinoTest.ino
deleted file mode 100644
index 2dfd133..0000000
--- a/ESP32Test/arduinoTest/arduinoTest.ino
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <Stepper.h>
-
-#define STEPS 200
-
-Stepper stepper(STEPS, 2, 3); // Pin 2 connected to DIRECTION & Pin 3 connected to STEP Pin of Driver
-
-#define motorInterfaceType 1
-
-int btnPin = 5;
-int ledPin = 6;
-int buttonState = 0;
-
-void setup() {
-
- stepper.setSpeed(1600);
- pinMode(btnPin, INPUT);
- pinMode(ledPin, OUTPUT);
-}
-
-void loop() {
-
- buttonState = digitalRead(btnPin);
-
- if(buttonState == HIGH){
- digitalWrite(ledPin, HIGH);
- stepper.step(1);
-
- //delay(5000);
-
- //stepper.step(-800);
- }
- else{
- digitalWrite(ledPin, LOW);
- }
-
-
-
-} \ No newline at end of file