So, I was trying to drive a motor using PWM based on the circuit in the Getting started with Arduino book (Image attached). However my circuit (the second image) does not behave as expected.
As soon as the power is turned on, the motor is on irrespective of the Arduino. In fact it works even if I disconnect the the arduino from the gate pin! I have replaced the mosfet, diode, resistor etc, in case there was a hardware problem but there is still no difference. Please hep me to find the mistake!