Also ich bekomme Deine Fragmente nicht kompiliert.
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino: In function 'void loop()':
sketch_dec02d:57:38: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
tmpTasterPressed = checkTaster();
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
sketch_dec02d:72:23: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
if (checkTaster() == pinTasterStop)
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
sketch_dec02d:95:28: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
if (checkTaster(false) == pinTasterStop)
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
sketch_dec02d:110:38: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
tmpTasterPressed = checkTaster();
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
sketch_dec02d:137:38: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
tmpTasterPressed = checkTaster();
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
sketch_dec02d:171:38: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
tmpTasterPressed = checkTaster();
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:210:10: warning: jump to case label [-fpermissive]
case FEHLER:
^~~~~~
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:190:15: note: crosses initialization of 'uint8_t returnStopfMaschine'
uint8_t returnStopfMaschine = StopfMaschine();
^~~~~~~~~~~~~~~~~~~
sketch_dec02d:213:23: error: too few arguments to function 'uint8_t checkTaster(bool, int)'
if (checkTaster() == pinTasterStop)
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:404:9: note: declared here
uint8_t checkTaster(bool delayEIN, int delayTime)
^~~~~~~~~~~
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:54:10: warning: enumeration value 'FEHLER' not handled in switch [-Wswitch]
switch (zustand)
^
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino: In function 'uint8_t checkTaster(bool, int)':
/tmp/arduino_modified_sketch_82541/sketch_dec02d.ino:407:29: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (millis() - prevMillis >= delayTime || !delayEIN)
~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
Bibliothek Adafruit_NeoPixel-master in Version 1.10.7 im Ordner: /home/user1/arduino-1.8.19/portable/sketchbook/libraries/Adafruit_NeoPixel-master wird verwendet
Bibliothek Servo in Version 1.1.8 im Ordner: /home/user1/arduino-1.8.19/libraries/Servo wird verwendet
exit status 1
too few arguments to function 'uint8_t checkTaster(bool, int)'
Der Sketch dazu
#include <Adafruit_NeoPixel.h>
#include <Servo.h>
//..............Servo..............
Servo servoLaden;
Servo servoStart;
#define pinServoLaden 9
#define pinServoStart 10
//..............Schrittmotor..............
#define pinStepperDir 11
#define pinStepperStep 12
#define pinStepperEnable 13
//..............Taster..............
#define pinTasterStop 6
#define pinTasterStart 7
//..............NeoPixel LED..............
#define pinNeoPixel 1
enum LEDFARBE {GRUEN, ROT, ORANGE, BLAU, LEDAUS};
Adafruit_NeoPixel pixels(1, pinNeoPixel, NEO_GRB + NEO_KHZ800);
//..............endschalter..............
#define pinEndschalter 2
//..............IR sensor..............
#define pinIRLed 8
#define pinPhotoDiode A0
//..............vibrator..............
#define pinVibrator 3
void setup()
{
Serial.begin(9600);
pinMode(pinTasterStart, INPUT_PULLUP);
pinMode(pinTasterStop, INPUT_PULLUP);
pinMode(pinStepperDir, OUTPUT);
pinMode(pinStepperStep, OUTPUT);
pinMode(pinStepperEnable, OUTPUT);
pinMode(pinEndschalter, INPUT);
pinMode(pinIRLed, OUTPUT);
digitalWrite(pinIRLed, HIGH);
pinMode(pinVibrator, OUTPUT);
pixels.begin();
pixels.setBrightness(20); //0 bis 255
pixels.show();
initialMotorServo();
}
void loop()
{
static enum ezustand {AUS, EIN, AUSRICHTEN, VIBRIEREN, STEPPER, LADEN, STOPFEN, FEHLER} zustand = AUS;
static bool OneCycle = false;
uint8_t tmpTasterPressed = 0;
//tvibrieren();
switch (zustand)
{
case AUS:
tmpTasterPressed = checkTaster();
if (tmpTasterPressed == pinTasterStop)
{
zustand = AUSRICHTEN;
}
else if (tmpTasterPressed == pinTasterStart)
{
zustand = EIN;
}
else
{
setNeoPixel(ROT);
}
break;
case EIN:
if (checkTaster() == pinTasterStop)
{
if (OneCycle)
{
zustand = FEHLER;
}
else
{
OneCycle = true;
setNeoPixel(ORANGE);
}
}
else
{
OneCycle = false;
setNeoPixel(GRUEN);
}
if (zustand != FEHLER)
{
zustand = VIBRIEREN;
}
break;
case AUSRICHTEN:
if (checkTaster(false) == pinTasterStop)
{
BlinkLED(250, BLAU); //Ausrichten
runStepper(true);
}
else
{
zustand = AUS;
}
break;
case VIBRIEREN:
vibrierenEin(4000);
zustand = STEPPER;
break;
case STEPPER:
tmpTasterPressed = checkTaster();
if (tmpTasterPressed == pinTasterStop)
{
if (OneCycle)
{
zustand = FEHLER;
}
else
{
OneCycle = true;
setNeoPixel(ORANGE);
}
}
else if (tmpTasterPressed == pinTasterStart)
{
OneCycle = false;
setNeoPixel(GRUEN);
}
if (zustand != FEHLER)
{
if (runStepper(false))
{
zustand = LADEN; //Schrittmotor 45Grad drehen
}
}
break;
case LADEN:
tmpTasterPressed = checkTaster();
if (tmpTasterPressed == pinTasterStop)
{
if (OneCycle)
{
zustand = FEHLER;
}
else
{
OneCycle = true;
setNeoPixel(ORANGE);
}
}
else if (tmpTasterPressed == pinTasterStart)
{
OneCycle = false;
setNeoPixel(GRUEN);
}
if (zustand != FEHLER)
{
if (runServo(2, 154, servoLaden)) //Zigihülse reinstecken
{
if (checkIR()) //Prüfen ob die Hülse richtig drauf ist
{
zustand = STOPFEN;
}
else
{
zustand = FEHLER;
}
}
}
break;
case STOPFEN:
tmpTasterPressed = checkTaster();
if (tmpTasterPressed == pinTasterStop)
{
if (OneCycle)
{
zustand = FEHLER;
}
else
{
OneCycle = true;
setNeoPixel(ORANGE);
}
}
else if (tmpTasterPressed == pinTasterStart)
{
OneCycle = false;
setNeoPixel(GRUEN);
}
//rückgabe wert wird in eine var. geschrieben damit die funktion nur einmal pro durchlauf ausgeführt wird
uint8_t returnStopfMaschine = StopfMaschine();
if (zustand != FEHLER)
{
if (returnStopfMaschine == 0)
{
zustand = FEHLER;
}
else if (returnStopfMaschine == 2)
{
if (OneCycle)
{
zustand = AUS;
}
else
{
zustand = STEPPER;
}
}
}
break;
case FEHLER:
Serial.println("Fehler");
BlinkLED(250, ROT);
if (checkTaster() == pinTasterStop)
{
zustand = AUS;
}
break;
}
/*if(zustand == FEHLER)
Serial.println("Fehler");
{
BlinkLED(250, ROT);
if(checkTaster() == pinTasterStop)
{zustand = AUS;}
}*/
Serial.println(zustand);
}
uint8_t checkTaster(bool delayEin = true, int delayTime = 500);
//rückgabe wert: 0 = fehler, 1 = noch nicht fertig, 2 = fertig
uint8_t StopfMaschine()
{
static enum {AUS, EIN, START, STOPFEN, FEHLER} zustand = AUS;
switch (zustand)
{
case AUS:
if (checkEndschalter())
{
zustand = EIN;
}
else
{
zustand = FEHLER;
}
break;
case EIN:
if (runServo(2, 40, servoStart)) //An der Stopfmaschine start drücken
{
zustand = START;
}
break;
case START:
if (!checkEndschalter())
{
zustand = STOPFEN;
}
break;
case STOPFEN:
if (checkEndschalter())
{
zustand = AUS;
return 2;
}
break;
case FEHLER:
zustand = AUS;
return 0;
}
return 1;
}
void initialMotorServo()
{
servoStart.attach(pinServoStart);
servoLaden.attach(pinServoLaden);
runServo(2, 10, servoLaden); //sicher stellen damit der servo in der richtigen pos. ist
runServo(2, 10, servoStart); //sicher stellen damit der servo in der richtigen pos. ist
digitalWrite(pinStepperEnable, LOW);
digitalWrite(pinStepperDir, LOW); //gegen den Uhrzeigersinn
delay(10);
}
void setNeoPixel(LEDFARBE val)
{
static LEDFARBE lastFarbe = LEDAUS;
if (lastFarbe != val)
{
lastFarbe = val;
switch (val)
{
case GRUEN:
pixels.setPixelColor(0, pixels.Color(0, 255, 0));
break;
case ROT:
pixels.setPixelColor(0, pixels.Color(255, 0, 0));
break;
case ORANGE:
pixels.setPixelColor(0, pixels.Color(255, 140, 0));
break;
case BLAU:
pixels.setPixelColor(0, pixels.Color(0, 0, 205));
break;
case LEDAUS:
pixels.setPixelColor(0, pixels.Color(0, 0, 0));
break;
}
pixels.show();
}
}
void BlinkLED(unsigned long interval, LEDFARBE farbe)
{
static bool LEDon = false;
static unsigned long prevMillis = 0;
if (millis() - prevMillis >= interval)
{
prevMillis = millis();
if (LEDon)
{
LEDon = false;
setNeoPixel(farbe);
}
else
{
LEDon = true;
setNeoPixel(LEDAUS);
}
}
}
bool runStepper(bool ausrichten)
{
static uint8_t LastStep = 1;
if (!ausrichten)
{
digitalWrite(pinStepperStep, HIGH);
delayMicroseconds(6000);
digitalWrite(pinStepperStep, LOW);
delayMicroseconds(6000);
if (LastStep >= 100) //Schrittmotor immer um 45 Grad drehen
{
LastStep = 1;
return true;
}
else
{
LastStep += 1;
return false;
}
}
else
{
digitalWrite(pinStepperStep, HIGH);
delay(30);
digitalWrite(pinStepperStep, LOW);
delay(30);
return true;
}
}
bool runServo(uint8_t startWinkel, uint8_t endWinkel, Servo &sObjekt)
{
static int LastWinkel = -1;
static bool Reverse = false;
if (LastWinkel == -1)
{
LastWinkel = startWinkel;
}
if (LastWinkel >= endWinkel || Reverse)
{
Reverse = true;
//In ausgangs position zurück drehen
LastWinkel -= 1;
sObjekt.write(LastWinkel);
delay(3);
if (LastWinkel <= startWinkel)
{
LastWinkel = -1;
Reverse = false;
return true;
}
else
{
return false;
}
}
else
{
LastWinkel += 1;
sObjekt.write(LastWinkel);
delay(3);
return false;
}
}
uint8_t checkTaster(bool delayEIN, int delayTime)
{
static unsigned long prevMillis = 0;
if (millis() - prevMillis >= delayTime || !delayEIN)
{
if (digitalRead(pinTasterStart) == LOW)
{
prevMillis = millis();
return pinTasterStart;
}
else if (digitalRead(pinTasterStop) == LOW)
{
prevMillis = millis();
return pinTasterStop;
}
else
{
return 0;
}
}
else
{
return 0;
}
}
bool checkEndschalter()
{
if (digitalRead(pinEndschalter) == LOW)
{
return true;
}
else
{
return false;
}
}
bool checkIR()
{
if (analogRead(pinPhotoDiode) <= 685)
{
return true;
}
else
{
return false;
}
}
unsigned long vibDauer = 0;
void vibrierenEin(int dauer)
{
vibDauer = dauer + millis();
}
void tvibrieren()
{
if (millis() <= vibDauer)
{
digitalWrite(pinVibrator, HIGH);
}
else
{
digitalWrite(pinVibrator, LOW);
}
}
Wenn Du das vergleichst und keinen anderen Code bringen kannst, ist das raten auf einem Level, was das ganze Wochenende brauchen wird um erstmal was grundlegendes hinzubekommen...