10 Replies Latest reply on Feb 10, 2018 6:02 PM by shabaz

    3V Motor Control using Arduino


      I'm not too familiar with Arduino's but I'm very interested to get involved with them as I would like to build my own projects!


      The circuit that I have built is shown below:


      I am trying to control 3V DC motor using the PWM pins on the Arduino. I'm using an LDR in a voltage divider to provide an analog input into the A0 pin. The code I'm using is provided below:


      int sensorPin = A0;   // select the input pin for the voltage read from sensor

      int motorPin = 9;     // select the pin for the motor

      int sensorValue = 0;  // variable to store the value coming from the sensor

      int val = 0;


      void setup() {

        //set the pin mode for the motor to be an output

        pinMode(motorPin, OUTPUT);




      void loop() {

        // read the value from the sensor:

        sensorValue = analogRead(sensorPin);


        //Print the value read on A0 into the serial monitor.


        Serial.print(' ');



        //sensorPin ranges between 0 -> 1023 so val ranges between 0 -> 255.

        val = sensorPin/4;


        //Motor speed changes relative to the value read at A0.

        analogWrite(motorPin, val);




      I can't see what is wrong with the circuit but the output voltage from the PWM pin 9 always seems to be roughly 0.05V and the VCC voltage 3.3V is all being dropped across VCE. Therefore I have concluded that there is no current flowing through the transistor.


      I am not sure how to solve this problem.


      Thanks for any help!

        • Re: 3V Motor Control using Arduino

          Hi Ross,


          I've not looked in detail (unfortunately I don't know Arduino so well either), so there could be more issues, but one thing that needs to change is the line:

          val = sensorPin/4;


          val = sensorValue/4;
          8 of 8 people found this helpful
          • Re: 3V Motor Control using Arduino

            Hi Ross,

            Let's break it into a couple of pieces. Test the transistor driver by taking the lead of Rb that is currently connected to the Arduino and move it between the collector of the transistor which should turn on the motor and the emitter which should turn off the motor. You have not indicated the part number of the transistor, nor whether you have used an NPN of a PNP. In this application the transistor should be an NPN. To test the Arduino you can connect an LED from the base end of Rb to the ground rail. Make sure the transistor's base isn't connected for this test. Once we have narrowed down where things aren't working we can revisit the other possible problems.


            7 of 7 people found this helpful
              • Re: 3V Motor Control using Arduino

                Hi John, thanks for the reply!


                I’ll certainly bare this in mind when it comes to testing the transistor, I appreciate the effort you’ve put into your reply it’s very helpful!


                Thank you for the compliment haha I feel it is much easier when diagrams are used instead of me just trying to explain my situation hahaha!


                Thanks again!

              • Re: 3V Motor Control using Arduino

                Hi Ross,

                I meant to compliment you on the excellent presentation that you made for your question. Good diagrams and background information make responding much easier and more on the point.


                2 of 2 people found this helpful
                • Re: 3V Motor Control using Arduino

                  I agree with jw0752. It's nice to see ALL the information.


                  Personally I'd drop the series resistor from 660 to 470ohm, or even down to 220.

                  Your calculation for the full collector current shows you need a 570 ohm and motors always require more current to start.


                  You may need an external 3v3 regulator or battery to power the motor.

                  While the 5v regulator on an Arduino can provide enough, the 3v3 has much less current capability.



                  The sensor to PWM conversion can also be done using MAP.


                  It allows some range selection to restrict output, and the example shows reading analogue and driving PWM.




                  6 of 6 people found this helpful
                    • Re: 3V Motor Control using Arduino



                      Thank you very much for your reply as this is very helpful and interesting information! I dropped the resistance down to 470 ohms and the motor has no bother starting up now! The higher current during start up is something I did not consider when designing the circuit so thank you!