Hallo zusammen,
ich bin neu hier und wollte eigentlich erst eine PN senden, das hat aber nicht geklappt
Ich bin Anfänger bei Arduino, würde aber trotzdem gerne etwas umsetzen und dabei lernen:
Ich suche für einen 12V Kinder Traktor einen Softstart Code. Ich habe hier einen Arduino Nano und zwei BTS7960B Motor Treiber, die Motoren haben jeweils 165W (2 Stück).
Ich habe bereits diesen hier gefunden:
#include <Noiasca_led.h> // download library from https://werner.rothschopf.net/microcontroller/202202_tools_led_en.htm ab Version 0.0.5
const byte DIR = 4;
const byte MOTOR_PWM = 6; // an PWM
const byte V_EN = 7; // vorwärts Freigabe; an RPWM oder LPWM
const byte R_EN = 8; // rückwärts Freigabe; an LPWM oder RPWM
const byte POTI = A0;
SmoothPin motor {MOTOR_PWM}; // UNO PWM pins 3, 5, 6, 9, 10, 11
void setup() {
pinMode(DIR, INPUT_PULLUP);
pinMode(V_EN, OUTPUT);
pinMode(R_EN, OUTPUT);
motor.begin(); // you have to call the .begin() method for the LED pair
motor.setMaxBrightness(0); // you can limit the maximum brightness. Highest value on Arduino is 255. Default 255.
motor.off(); // you can switch the LED off
motor.setOnInterval(5); // you can modify the delay time for the smothing
motor.setOffInterval(1); // you can modify the delay time for the smothing
}
void loop() {
const uint8_t MAX_VORWAERTS = 250;
const uint8_t MAX_RUECKWAERTS = 85;
static uint8_t schritt = 0;
uint8_t geschw = analogRead(POTI) / 4;
switch (schritt)
{
case 0:
if (digitalRead(DIR))
{
digitalWrite(R_EN, LOW);
digitalWrite(V_EN, HIGH);
if (geschw > MAX_VORWAERTS) geschw = MAX_VORWAERTS;
motor.setMaxBrightness(geschw);
motor.on();
} else {
digitalWrite(R_EN, LOW);
digitalWrite(V_EN, LOW);
motor.off();
if ( motor.getCurrentBrightness() <= 2 ) schritt = 1;
}
break;
case 1:
if (!digitalRead(DIR))
{
digitalWrite(V_EN, LOW);
digitalWrite(R_EN, HIGH);
if (geschw > MAX_RUECKWAERTS) geschw = MAX_RUECKWAERTS;
motor.setMaxBrightness(geschw);
motor.on();
} else {
digitalWrite(R_EN, LOW);
digitalWrite(V_EN, LOW);
motor.off();
if ( motor.getCurrentBrightness() <= 2 ) schritt = 0;
}
break;
}
motor.update(); // you have to call update() for the LED
}
Er stammt von @agmue aus dem Kinder Kart Motor Thema.
Problem ist, ich habe keine Poti sondern nur einen einfachen EIN/AUS Schalter und einen Schalter welche Geschwindigkeit 1/2 und Rückwärts steuert.
Sobald Schalter auf 1 steht, soll 50% Geschwindigkeit ausgegeben werden, Schalter 2 soll 100% erzeugen. Rückwärts soll 35% Rückwärts erzeugen. Das ganze halt mir dem Soft Start.
Kann mir jemand behilflich sein das umzuschrieben?
Ich hoffe ich habe alle Regeln hier befolgt.