user40923: I have Arduino Uno and I attached it to 2 DC motors with L298N bridge. 
I want to control the speed of the motors so they don't move at maximum speed. 
I use analogWrite() but it does nothing,and the motors move at maximum speed
Here is my code:
//motor A
int enA = 9;
int in1 = 8;
int in2 = 7;

//motor B
int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop() {

  analogWrite(enA, 0);

  analogWrite(enB, 0);

  digitalWrite (in1, HIGH);
  digitalWrite (in3, HIGH);
  digitalWrite (in2, LOW);
  digitalWrite (in4, LOW);

  delay(50);
}


user40931: analogWrite() can take values between 0 and 255 as its second parameter. Where 255 will give you the maximum motor speed and 0 will give you the lowest (motor will not run).
For example, below code will give you almost the half of max speed.
analogWrite(enA, 128);  
analogWrite(enB, 128);


user40923: I did find solutions for the problem. It turned out that the bridge does not work as it should be and the pins of en(A,B) is replaced with the in pins ..now I can control the speed but can't reverse the direction of the motors 

40923: <p>I have Arduino Uno and I attached it to 2 DC motors with L298N bridge. 
I want to control the speed of the motors so they don't move at maximum speed. 
I use <code>analogWrite()</code> but it does nothing,and the motors move at maximum speed</p>

<p>Here is my code:</p>

<pre class="lang-cpp prettyprint-override"><code>//motor A
int enA = 9;
int in1 = 8;
int in2 = 7;

//motor B
int enB = 3;
int in3 = 5;
int in4 = 4;

void setup() {
  Serial.begin(9600);
  pinMode(enA, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
}

void loop() {

  analogWrite(enA, 0);

  analogWrite(enB, 0);

  digitalWrite (in1, HIGH);
  digitalWrite (in3, HIGH);
  digitalWrite (in2, LOW);
  digitalWrite (in4, LOW);

  delay(50);
}
</code></pre>
 40931: <p>analogWrite() can take values between <strong>0</strong> and <strong>255</strong> as its second parameter. Where 255 will give you the maximum motor speed and 0 will give you the lowest (motor will not run).</p>

<p>For example, below code will give you almost the half of max speed.</p>

<pre><code>analogWrite(enA, 128);  
analogWrite(enB, 128);
</code></pre>
 40923: <p>I did find solutions for the problem. It turned out that the bridge does not work as it should be and the pins of en(A,B) is replaced with the in pins ..now I can control the speed but can't reverse the direction of the motors </p>
