LMD298 doesnt drive till analogpin has no voltage

Hi,

i have following code:

#include <Arduino.h>

#define DIRA 6
#define DIRB 5

uint8_t tst = 0;
int EcuMdMinusPIN = A1;
int ECUMDMinus; //Signal-close

void setup()
{
  Serial.begin(9600);

  pinMode(DIRA, OUTPUT);
  pinMode(DIRB, OUTPUT);

  digitalWrite(DIRA, LOW);
  digitalWrite(DIRB, LOW);

  digitalWrite(DIRA, HIGH);
  digitalWrite(DIRB, LOW);

  delay(1000);
  digitalWrite(DIRA, LOW);
  digitalWrite(DIRB, HIGH);
  delay(1000);

  digitalWrite(DIRA, LOW);
  digitalWrite(DIRB, LOW);
}

void loop()
{
  ECUMDMinus = analogRead(EcuMdMinusPIN);
  if (ECUMDMinus > 100)
  {
    if (!tst)
    {
      tst = true;
      Serial.println("Motor soll fahren");
      digitalWrite(DIRA, HIGH);
      digitalWrite(DIRB, LOW);
    }
  }
}

In the setup i use a LMD298 to drive a electric motor first to the left, than to the right. In the loop function i wait till i have voltage on ECUMDMinus. If i have voltage on it i set the LMD and the electric motor drives to the right.

Now to the behavior i didn´t unterstand:

If i have voltage on ECUMDMinus i print on Serial "Motor soll fahren" but the electric motor doens´t turn to a direction. If I release the Voltage on ECUMDMinus the electric motor starts to turn.

Why is that so? In my understanding the motor should start in that moment i have voltage on ECUMDMinus ?!

To get help you should:

Read the forum guidelines.
Post your code.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Post a schematic of the project.
Post data sheets for all major components.

Try printing the value of ECUMDMinus to serial monitor after it is read. Maybe you will be surprised by the values.

Difficult to say without a schematic, but understand that there is always a voltage on ECUMDMinus, there is always a voltage on everything, that's basic physics. Whether the voltage is what you think it is is a different question. With that in mind what do you really mean by there being and not being a voltage on ECUMDMinus?

Solved.

Thanks.

Sorry, don't know the answer to your question, but having a schematic will most likely help someone else to help you.

I found out that i have a hardware problem here.

I will check this

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.