ok das ist doch mal ne gute Idee von dir werde ich gleich mal so um setzen und ausprobieren
- - - Aktualisiert - - -
ok es funktioniert habe es jetzt mal so gelöst
Code:/* Analog Input */ #define MOTOR_1 2 #define MOTOR_2 4 #define POTI A0 #define PWM 9 #define TASTER 7 #define LED 3 //int poti = A0; // select the input pin for the potentiometer int poti_Value = 0; // variable to store the value coming from the sensor int poti_prozent = 0; bool sicherheit = 1; void setup() { // declare the ledPin as an OUTPUT: //pinMode(ledPin, OUTPUT); Serial.begin(9600); //pinMode(MOTOR_1,OUTPUT); //pinMode(MOTOR_2,OUTPUT); pinMode(LED,OUTPUT); pinMode(TASTER,INPUT_PULLUP); pinMode(MOTOR_1,OUTPUT); pinMode(MOTOR_2,OUTPUT); pinMode(PWM,OUTPUT); digitalWrite(LED, LOW); // Sicherheitsschaltung Poti auf 0 und Motor Aus poti_Value = analogRead(POTI); poti_prozent = map(poti_Value, 0,1023, 0,100); while( poti_prozent >= 3 ) { digitalWrite(MOTOR_1, HIGH); digitalWrite(MOTOR_2, HIGH); digitalWrite(LED, HIGH); delay(300); poti_Value = analogRead(POTI); poti_prozent = map(poti_Value, 0,1023, 0,100); digitalWrite(LED, LOW); delay(300); } } void loop() { int pwmSpeed; // Poti Regelbereich poti_Value = analogRead(POTI); poti_prozent = map(poti_Value, 0,1023, 0,100); // Ausgabe Serial.print("Poti = "); Serial.print(poti_prozent); Serial.println("% "); //delay(1000); digitalWrite(MOTOR_1, HIGH); digitalWrite(MOTOR_2, HIGH); // Geschwindigkeit regeln analogWrite(PWM, poti_Value / 4); // Drehrichtung Links digitalWrite(MOTOR_1, HIGH); digitalWrite(MOTOR_2, LOW); // Drehrichtung Rechts digitalWrite(MOTOR_1, LOW); digitalWrite(MOTOR_2, HIGH); //digitalWrite(LED, HIGH); //delay(1000); // ENDE }







Zitieren

Lesezeichen