Can´t control more than one digital output

Hi everyone, I´m trying to make an h bridge controlable by the serial monitor and just turns for one way and I can stop it with the program below. When I try to set the other way turning I haven´t a high output which comands the other way, and it don´t works. What can I try to do?

proga.txt (447 Bytes)

OP's code

char a = 0;
void setup()
{
  Serial.begin(2000000);
  pinMode(8, OUTPUT);
  pinMode(12, OUTPUT);
}
void loop() {
  if (Serial.available() > 0)
  {
    a = Serial.read();
    Serial.print(a);
    Serial.print("\n");

    if (a == 'e')
      digitalWrite(12, HIGH);

    if (a == 'a')
      digitalWrite(8, HIGH);
    digitalWrite(12, LOW);


    if (a == 's')
      digitalWrite(8, LOW);
    digitalWrite(12, LOW);

  }
}

If() statements with more than one line need curly braces.
Leo..

After you can put things like this: firstly switch the high pin LOW, and after seitch the low pin HIGH.
But haven't you a way to switch the motor (or whatever into the H bridge) completly off?) witchout turn of piwer?

Serial.begin(2000000);

I don’t think an Arduino can go that fast.

It's the highest baud rate on the serial monitor, and works fine here.
Leo..