I first pulled down the outputs 9 and 10 to GND with 13K7 resistor.
Same problem.
Then added the code that controls the outputs below the pinmode declarations
Same problem.
Then I moved it up directly under serial begin.
Problem solved.
Thanks for your cooperation. I hope others benefit from it too.
void setup()
{
Serial.begin(9600); // Output to serial writing or BT
speedfinalValue = 0; //this value determens if the motor is running. if value = 0 then PWM signal = 0
brakeNValue = 0; //this value determens if the motor is braked. if value = 0 then PWNM signal = 0
pinMode(led7Pin, OUTPUT); // initialize the led as a output control pin //
pinMode(led8Pin, OUTPUT); // initialize the led as a output control pin //
pinMode(led12Pin, OUTPUT); // initialize the led as a output control pin //
pinMode(led13Pin, OUTPUT); // initialize the led as a output control pin //
//pinMode(11,INPUT); //for calibration push button
//digitalWrite(11, HIGH); // enable the 20k internal pullup for MEGA board
digitalWrite((54), HIGH); // enable the 20k internal pullup for MEGA board