const int stepPin = 3;
const int dirPin = 4;
int freig1 = 5;
int freig2 = 6;
int voll = 7;
int pump1 = 8;
int pump2 = 9;
int pump3 = 10;
int zylinder = 11;
int myNextion = 1;
void pos1 (void)
{
digitalWrite(dirPin,HIGH); // Schlitten fährt zu Position 1
for(int x = 0; x < 2000; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
void grundpos1 (void)
{
digitalWrite(dirPin,LOW); //Schlitten fährt in Grundpostion von Position 1
for(int x = 0; x < 2000; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
void pos2 (void)
{
digitalWrite(dirPin,HIGH); // Schlitten fährt zu Position 1
for(int x = 0; x < 3000; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
void grundpos2 (void)
{
digitalWrite(dirPin,LOW); //Schlitten fährt in Grundpostion von Position 1
for(int x = 0; x < 3000; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
void setup() {
// Sets the two pins as Outputs
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(freig1,INPUT);
pinMode(freig2,INPUT);
pinMode(voll,INPUT);
pinMode(pump1,OUTPUT);
pinMode(pump2,OUTPUT);
pinMode(pump3,OUTPUT);
pinMode(zylinder,OUTPUT);
}
void loop() {
String message = myNextion.listen(); /Warten Befehle vom Nextionpanel
{
if (message != "") // Eingabe von Touchpanel (Serielle Schnittstelle)
}
{
if (freig1=HIGH,freig2=HIGH); // Input 1/2 aktiv
int delay = 1000; // Motor wird zum ersten Dispenser gefahren
pos1();
}
{
delay(10000); // 10 Sekunden delay
digitalWrite(zylinder,HIGH);
delay(6000);
digitalWrite(zylinder,LOW);
}
{
int delay = 5000; // Motor fährt zurück in Grundposition
grundpos1();
}
{
if (freig1=HIGH,freig2=HIGH); // Input 1/2 aktiv
{
while(voll=LOW) // Solange das Glas nicht voll ist läuft die Pumpe 1
{
(pump1,HIGH);
}
}
}
}
{
if (freig1=1,freig2=1) // Eingabe von Touchpanel (Serielle Schnittstelle)
{
if (freig1=HIGH,freig2=HIGH); // Input 1/2 aktiv
int delay = 1000; // Motor wird zum ersten Dispenser gefahren
pos2();
}
{
delay(10000); // 10 Sekunden delay
digitalWrite(zylinder,HIGH);
delay(6000);
digitalWrite(zylinder,LOW);
}
{
int delay = 5000; // Motor fährt zurück in Grundposition
grundpos2();
}
{
if (freig1=HIGH,freig2=HIGH); // Input 1/2 aktiv
{
while(voll=LOW) // Solange das Glas nicht voll ist läuft die Pumpe 1
{
(pump2,HIGH);
}
}
}
}
}
Schaut euch bitte diesen Code mal an, was hält ihr davon?
Das mit der Seriellen Schnittstelle funktioniert noch nicht, da muss ich mich noch vertiefen.