BLOG > Tutorial 5 for Arduino: Motors and Transistors

This tutorial was featured on the official Arduino blog on 3/9/2011

This week, we’ll finally be using the Arduino to control some motors!  First up, we’ll control a standard DC motor running off a 9V battery with the help of an NPN transistor and a PWM (Pulse Width Modulated) signal from the Arduino.  Next, it’s onto 180 degree servo motors, which we will power on an independent 5V rail using a voltage regulator.  We’ll control the servo using a PWM signal from the arduino, and I’ll show you how you can turn analog distance readings into precise angles for the servo to turn to!

I mention in the video that you can control DC motor direction using an H-Bridge.  If you want to wire that up, take a look through this Wikipedia article, and read through this tutorial.

If you want to learn more about analog input filtering in software, check out this example code.

The Arduino Contest has been extended!  So don’t forget to submit your project.


You can download the files associated with this episode here:

GNU GPL License Distributed under the GNU General Public (Open-Source) License.
Please Attribute and Share-Alike.


301 comments

  1. hi jeremy, i am student of engineering Electromechanical, I would you like to talk about how to connect LCD and how to program in Arduino, Thanks. I admire your work. Greetings from Mexico

  2. hi , jeremy ..i need some help… i wana rotate the servo motor first clk-wise then anti-clk-wise…. say 30 degrees clk-wise first then 30 degrees anti-clk-wise… how should i do it ?

    1. #include

      Servo myservo; // create servo object to control a servo
      // a maximum of eight servo objects can be created

      int pos = 0; // variable to store the servo position

      void setup()
      {
      myservo.attach(9); // attaches the servo on pin 9 to the servo object
      }

      void loop()
      {
      for(pos = 0; pos =1; pos-=1) // goes from 180 degrees to 0 degrees
      {
      myservo.write(pos); // tell servo to go to position in variable ‘pos’
      delay(15); // waits 15ms for the servo to reach the position
      }
      }

        1. Just email me . I will send the 30 degree one direction and 30 the other.. I just setup for you here and it works..

          topper727 AT yahoo.com

  3. Hello Jeremy,
    I’m watching your tutorial and it’s so helpful.

    I have a question about the DC motor circuit , when I connect the circuit everything in the circuit become very hot why is that?

    And is it correct to connect the different grounds in one vertically connected line in breadboard ?

  4. Hi Jermey,

    I downloaded the servo example script you wrote, I have it all wired correctly and the signal gets to the servo but it spins to the end of its rotation and stays. It seems to not acknowledge the commands in the script…. PLEASE help going crazy here regards Chris

  5. Hi,
    I built your first circut in this video except I changed the motor to a small fan which should not make any difference and my circut isnt working. I am trying to figure out if it has to do with the npn transistor that I am using. Does it matter what kind of npn transistor your using? for example a switching transistor or a small signal transistor.

    please respond

    1. It shouldn’t matter what NPN transistor you use, but it’s certainly possible that some will not work for this application depending on their turn-on voltages, etc.

      1. It can matter what transistor is used. Not all transistors use the same pin configuration. You may need to either find the part number of your transistor and look up pinout in the data sheet, or else test the transistor.

    2. I also tried to build this substituting a fan for a motor. My circuit works, but the fan spins very slowly. Not even close to when I connect it directly to 12V. Is it possible that my Arduino isn’t giving enough power to the transistor? Thanks

      1. It is possible that your fan motor is brushless with it’s own drive circuitry in the motor. PWM might prevent that circuitry from receiving a stable voltage and working properly. Try your circuit with a simple 12 Volt permanent magnet hobby motor.

        Some motor types like Steppers and brushless DC are not run with PWM. Arduino will run Steppers beautifully.

  6. One of the best tutorials. I love the way you “spoon feed” us all. LOL

    Thanks for great tutorial series!

  7. Jeremy! Hi! I just received my Uno over the weekend and it’s so much better using the real thing rather a mock up I made on a breadboard (cool, but not as cool). Anyways, I don’t know if anyone pointed it out yet, but when you’re going through the script for the first motor, methinks you forgot to declare “i” before the “for” funcion, else (lol) one will get errors. Happened but me. Just wanted to point that out! Diggin’ the tutorials! Great job!

    1. From what I understand (and he mentions it, I think) a motor will want to pull more power than the duino can provide. It can run it, but it’s not recommended. That’s where a separate power source for the motor comes in. If you want to be able to power it for any practical use, it should have its own power source. And I’d also like to amend my previous comment…turns out it wasn’t necessary to declare “I”. Not sure what I wrote, but if I didn’t declare “I” with int, it wouldn’t work. So I rewrote it, and it worked fine without int. Not sure what happened there tho…

      1. Stitch is correct. The Arduino (or more precisely, the ATMega) can output a max of 20mA on one I/O pin. This may be enough for some motors, but most require more, which I why I recommend using a transistor and seperate power supply.

  8. Understand you. I thought Motor shield need for H-bridge and npn- transistors for motors on 5V<.
    I have bot and on plate all "motor's pin" reserved, but he must shoot (airsoftgun). Solution: create simple plate from video =) Use resistor, transistor, capacitor, diod and parallels connect on 9V batery and one pwm pin for controll. Thank's

  9. Hi Jeremy,

    You’re the best in tutorials, clear and inspirational. Good job with the Facebook2: go and do more useless stuff while you’re young. Great learning experience!
    I used stepper.h but that did not seem to work with a 5Volt 5 wire 28BYJ-48 stepper motor. I assume that is very different from a servo?

  10. Well, I burned a couple of transistors, while not thought to use the mosfet. However, the contacts, through which I want to give signals to the arduino, I talk about equal to 1A. Tell me, is it ok? Is not it dangerous for Arduino? And if so, how can you improve the situation? thanks

  11. Hey Jeremy,

    I built the identical circuit to what you had in your video and was excited when it worked. I was playing around with the code and got many different results that I wanted. I recently moved however, packed my stuff up and transferred locations. When I unpacked my circuit was in pieces. I rebuilt it easily seeing as it isn’t that complicated. I now can’t get it to work. My Arduino board is fine as I’ve tested it with different circuits, but this is really bugging me. I’ve swapped many different transistors thinking the gate is somehow is not working properly. Whenever I put a diode into the circuit (tried several types) it doesn’t run. The only thing I can do is get the motor spin with no control. The transistor(s) is/are working since disconnecting the pwm pin from the collector the motor won’t spin. I know you must get tired of answering tedious questions such as this, especially with such limited information, but any help would be greatly appreciated.

    Thanks!

      1. Sorry, I meant *Base before instead of Collector before…

        :S No, I flipped all the parts one by one to try to isolate what is going wrong. I definitely had them in the right way before. I wish I could throw up a picture. It looks identical to yours. I might be going with an H-Bridge Shield soon anyways. It’s just driving me crazy that I can’t figure this simple circuit out. I’ve used 2n4401 and 2n3904 transistors. swapped the 1k resistors, the 1uf capacitor, and diode…

        Sorry again, but I don’t have anyone I know to troubleshoot with. And I’ve read up on what you’ve done of course and can assume that you’re very patient.

        I’m just waiting for the point where it all makes complete sense of why it isn’t working. That rush and natural high you get from conquering something “complex”.

        Cheers!

      1. Please help me!)
        For a month I try to build a scheme for on and off the motor (at constant speed and the same direction of rotation), but nothing works. I tried to do it myself and use some other of google.
        Give me a link please, on the scheme or give advice- how I can create this.
        I think is not only my problem and your answer be topical for many DIY-men’s =D
        Thanks!

  12. Hi Jeremy,

    I have 12V 2000Rpm DC motor with a good torque. I applied directly 9V from battery and I got satisfactory torque such that I could not stop with my hand. But hen I connect them to Arduino that you show in the video (1kohm + NPN Transistor + 1Microfarad + diyot), and wrote your code, I couldn’t get enough torque. I see that it slowly increase the speed and decrease the speed but the peak value was not strong enough..

    What do you suggest? Is there anything wrong that I do?

    1. A Bipolar Transistor is a current controlled device. They generally have a gain of between 30 and 300. The base current will be (5VoltsArduinoOut – 0.8VoltsBaseEmitter)/1000Ohms or 4.2mA and at 30 gain that would allow 126mA of Collector current which is not likely to be enough for your powerful motor. In fact at 300 gain (rare transistors with optimal bias) the collector current would be 1.26A but that still might not be enough. When the collector current does not completely drop applied voltage across a greedy load, the transistor is likely to go up in smoke because the remaining voltage will be across the transistor. You can switch reasonable currents with a transistor as long as there is near zero voltage left across the transistor from collector emitter. Voltage and current equals power dissipation = heater, Might work with poor efficiency if you use a power transistor that is properly heat sinked, or else you are very likely to cause smoke.

      There are several ways to make a minor substitution that would allow this simple circuit to work.

      One is to use a Darlington transistor like a TIP120. These are basically stacked transistors that multiply the total gain. 1000 gain is typical for Darlingtons. (5VoltsArduinoOut – 1.5VoltsBaseEmitter)/1000Ohms = 3.5mA base current. At 1000 Gain you would get upto 3.5 Amps of current through the collector emitter.

      Another way is to use a MOSFET with a logic level gate.
      For anyone starting out I would say that a Darlington is going to be much more user friendly. You can kill a Mosfet by touching it because the gate is a delicate insulator very prone to damage by electrostatic discharges.
      Using a mosfet is still a great way to go, but always make certain that you observe ESD safety and buy at least two mosfet transistors and probably more so that you have spares.

      For a slightly more involved build you can use a motor driver IC. Starting out with a motor driver IC will not give you the same learning experience as this tutorial intends.

      I hope this helps and good luck!

  13. jeremy, im an ECE student.can you please show me a video about arduino uno to sim900 gsm module?
    anything would do as long as those two things are present. thanks

  14. Hi, great tutorial! im working with an hydraulic motor and arduino any other variable you recommend. But my motor has to extend the arm and retracted so my mechanism works as it supposed to, but in the store told me, to make the arm retracted i had to invert the polarities, any way i do this with programming or in the board of arduino.
    I would appreciate a lot..! :)

  15. Hey jeremy.. i beg for your help..
    I have a sharp ir sensor and a servo..
    i want a code so that the servo keep on rotating from 0 to 90 to 180 to 90 to 0 and at the same time i can see the value of that sensor on the serial monitor.
    So please can you write me up a code for that..??
    I wuld be so thankful to u.
    mail me that to [email protected] asap

  16. There seems to be two methods for using the diode. Some tutorials advocate bridge the transistor C and E with it, while yours and some others advocate bridging the two legs of the motor. Why the difference? Are the others wrong, or just another way of doing things?

    See

    1. It’s called a flyback diode, read more here: http://en.wikipedia.org/wiki/Flyback_diode
      The purpose is to eliminate the sudden voltage spike that can result across an inductive load when the supply voltage is rapidly removed. The motor is the inductive load, not the transistor, so I’m not sure why you would want that diode across the transistor, but maybe I’m missing something. I’ve only ever seen it across the motor, as I demonstrated.

      1. Across the motor the diode works as a low impedance path and the motor freewheels.

        Across the transistor the diode is a brake. The motor switches to a generator and returns power to the source. This is good for stopping the motor faster, and can regenerate some power back into a battery or capacitors. This has also been used as a way to convert power supply voltages. You can easily switch a low voltage high current motor to generate higher voltage lower current power or the other way around.

  17. hey jeremy blum,

    i would first like to say that your website is awesome!
    ok so i have a question,
    i am currently working on an invention sorta thing and i will be entering the dallas regional sciencefair sometime during february,my goal is to try my best to get past the regional fair and into the state fair which will be held in san antonio but that’s not where i will stop..i am also planning to go as far as international..i have very high hopes.i have looked all around the internet for help on one thing that im stuck on,and obviously no response because i cant seem to find anyone as good as you with arduinos and no one has ever created the thing i’m trying to create before.so now my request is if you can please please email me your number to ask you a question because i have lots of hard times understanding what people are trying to say through email.this is a really important project im working on to help the world and if you can help then that’ll be so awesome!
    if money is needed then that hopefully shouldn’t be a problem.

    (sorry for grammar mistakes i was in a hurry..(my email is [email protected])

    (p.s. and if anyone out there which has good knowledge with arduinos then please dont hesitate to email me,thanks!!)

  18. hi
    i know that if i conect a dc motor directly into one of my i/o pins it can fry my arduino uno but my question is why??

    thanks for the great tutorials and support.

    1. DC motors are inductive coils. The inductive kickback from a motor can destroy the I/O pins on your Arduino. Plus, it probably needs more current than your Arduino can source.

  19. Hi Jeremy,

    you use the binding post to connect all the ground between all your voltages. How can I accomplish this with a breadboard with no binding post?

  20. hi. i’m new in arduino and project. can i know what is the different between DC motor and Micro Metal Gear motor? is the programming need to change?

  21. Dear Jeremy,

    Your videos are amazing. I want to know can an arduino get 4 values from computer simultaneously. I know that AVAILABLE FUNCTION gets Char data, but little confused how can that char value be used. Example below should give you an idea what I am looking for.

    eg: Suppose computer sends a signal to arduino which is 4567

    I want to get 4, 5 , 6, 7 separately so that these values can be used separately for running 4 separate DC motors.

    Is there any other way to represent 4567 data computer in a different format may be like 4,5,6,7 when AVAILABLE function reads it comma can be ignored and rest of that can be used.

  22. hey Jeremy,

    just want to ask, i followed your tutorial for the voltage regulator, i have a 9 volts input and 4.75 volts out to be exact, iwhen i tried to hook up 4 servo motors to it, its not getting 4.75 volts , its getting less why is that?

  23. Hey man, awesome videos, although i can’t get the servo to work, I followed you tutorial and built the circuit exactly as you did, but the servo went completely haywire. I connected the servo’s red wire to the dedicated 5V supply, the brown wire to the common ground and the orange one to pin 9. I uploaded the program, but the servo just went crazy. It spins all the way up to one side, then it struggles a bit (i think it wants to rotate more), then it freezes, rotates the other way, and so on. the delay() function has absolutely no effect either. what am i doing wrong? i tried shuffling the servo’s wires a few times, maybe i messed up, but that wasn’t it. Any help is greatly welcome.

      1. Well, on the website where i ordered it from ( robofun.ro ), it said that its range was 0 – 180 degrees, but in the comments someone said that it only rotated on an interval of about 150-160 degrees. I tried experimenting a bit with it, thinking maybe its potentiometer was out of sync. I took out the screws and opened the plastic case. I gave the servo a command from the arduino to rotate to 0. I also pulled out the stopper pin from the servo’s axis. The motor started rotating continuously and with some pliers i started rotating the potentiometer, until the rotation stopped. It worked for a while, I managed to find the 0, 10 and 20 degree marks, but after that the servo just went haywire. And about your first question, I don’t know how to check for that.

  24. Hi jeremy regards from turkey, what i want to ask if i want to controll let say 120 watt lamb or very high voltage requring equipment with independent power supply as you instructed.doesnt it burn the my little arduino

    thanks;

    1. You need a Relay to control things like that. They are very simple to work with specialy if you ger one in a shield.

  25. There are concerns when using a relay or solenoid as well because of the CEMF voltage from the coil.

    You would also need a transistor between the arduino output and the relay coil. This is done the same way that is explained in this tutorial for driving motors.

    Optocouplers and Solid State Relays are another option.

    The problem is that for liability reasons it is very unwise to offer too much help in connecting to mains voltage. You have basically torn up your insurance policy for your home if you start doing any experimenting with 120volt AC or 220 and it goes wrong. The chance that you might hurt yourself or even die from high power shocks is also discouraging.

    Basically if you need to ask questions about how to hook up high power circuits the answer is always don’t do it; unless you are enrolled in an electricians course. A little knowledge can be very dangerous. You need to fully understand a whole lot of surrounding material before any answer can be certain, Small mistakes can just become far to serious.

    Amateur Electricians die with shocking frequency.

  26. Hey jeremy.im working on my final year proj and i need some help.

    Will my circuit work if i replace only ur servo motor with a stepper motor?

  27. Small biploar Steeper Motors and the Adafruit motor shield + library are great for learning the basics of steppers.

    You can find small stepper motors in many places, but I suggest you look for old scanners like you might find in a cheap multifunction inkject printers.

    Ask people you know and chances are somebody has one of those old inkjets they would be glad to donate = throw away.

  28. I have been working on this car robot for a while and Its almost complete except for my program. Basically its just suppose to control it self. When it hits a wall, it will back up and move a different direction.

    So basically my robot car is basically 2 motors at the back with wheels attached to it. I got my breadboard and Aduino hooked up. I have a potentiometer up at the front. Basically what I am trying to do is

    When the knob is set at the middle, both motors are moving forward. But once

    i turn the knob left > Both motors go off except The right motor goes backward for 2 seconds and then both motors go on Forward.
    i turn the knob right > Both motors go off except The left motor goes backward for 2 seconds and then both motors go on Forward.

    How would I do this.

    Much appreciated.

  29. Hey J,

    What change in the code would you need to run 2 or more motors at different times? Im wanting to make them fire off in sequences eg half a second after each other.

    Thanks

  30. When the robot see the bar, robot always right wheel revert. This code is below. Where is wrong code?

    #include
    const int M1 = 13; // direction motor 1
    const int M2 = 12; // direction motor 2
    const int M1BRAKE = 9; // pwm motor 1
    const int M2BRAKE = 8; // pwm motor 2

    #define TRIGGER_PIN 4
    #define ECHO_PIN 5
    const int MAX_DISTANCE = 200;
    Servo Servo1; // servo objects

    int leftDistance, rightDistance, fwdDistance;
    Servo SRF6AServo; // servo objects
    void setup() {
    Serial.begin(57600);
    pinMode(13, OUTPUT); // direction motor 1, left front
    pinMode(12, OUTPUT); // direction motor 2, left rear

    pinMode(8, OUTPUT); // motor 1 BRAKE
    pinMode(9, OUTPUT); // motor 2 BRAKE
    pinMode(3,OUTPUT);
    pinMode(11,OUTPUT);
    pinMode(TRIGGER_PIN, OUTPUT);
    pinMode(ECHO_PIN, INPUT);

    SRF6AServo.attach(10);
    SRF6AServo.write(55) ; // set servo to center pois
    delay(150);
    }
    void loop() {
    long duration, distance;
    digitalWrite(TRIGGER_PIN, HIGH);
    // delayMicroseconds(1000); – Removed this line
    delayMicroseconds(10); // Added this line
    digitalWrite(TRIGGER_PIN, LOW);
    duration = pulseIn(ECHO_PIN, HIGH);
    distance = (duration/2) / 29.1;
    digitalWrite(TRIGGER_PIN, LOW); // Added this line
    delayMicroseconds(2); // Added this line

    fwdDistance = distance;
    delay(100);
    if (fwdDistance > 15)
    {
    forward();
    }
    else
    {
    stop();
    SRF6AServo.write(110); // move servo left
    delay(500);
    leftDistance = distance;
    delay(100);
    SRF6AServo.write(10); // move servo right
    delay(500);
    rightDistance = distance;
    delay(100);
    SRF6AServo.write(55); // move servo to center
    delay(50);
    compareDistance();
    }
    }
    void compareDistance()
    {
    if (leftDistance>rightDistance) //if left is less obstructed
    {
    turnleft();
    delay(800);
    }
    else if (rightDistance>leftDistance) //if right is less obstructed
    {
    turnright;
    delay(800);
    }
    else if (rightDistance = leftDistance)
    {
    turnleft();
    delay(1500);
    }
    }

    void turnleft()
    {
    digitalWrite(13, LOW);
    digitalWrite(12, HIGH);
    digitalWrite(8, LOW); // motor 1 BRAKE
    digitalWrite(9, HIGH); // motor 2 BRAKE
    analogWrite(3, 130);
    analogWrite(11, 130);
    delay(3000);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);

    }
    void turnright()
    {
    digitalWrite(13, HIGH);
    digitalWrite(12, LOW);
    digitalWrite(8, HIGH); // motor 1 BRAKE
    digitalWrite(9, LOW); // motor 2 BRAKE
    analogWrite(3, 130);
    analogWrite(11, 130);
    delay(3000);
    digitalWrite(8, HIGH);
    digitalWrite(9, HIGH);

    }
    void forward()
    {
    digitalWrite(13, HIGH);
    digitalWrite(12, HIGH);
    digitalWrite(9, LOW); // motor 1 BRAKE
    digitalWrite(8, LOW); // motor 2 BRAKE

    analogWrite(3, 70);
    analogWrite(11, 70);

    }
    void stop()
    {
    analogWrite(3, 0);
    analogWrite(11, 0);

    }

  31. Thanks for this great tutorial. I have a motor running at 14.4v and around 2amps for a robotics project. I built the circuit you described with a Darlington NPN but left out the 1k resistor, diode, and 1 uf capacitor. The circuit worked for awhile and then my PWM pin stopped working. I tested it and it was no longer capable of supplying 5v, so I guess I burned it out somehow. Will adding those components I left out prevent this from happening again?

    Thanks,
    William

      1. With the high gain of a Darlington it needs very little input current. The max current an output pin of arduino should supply is 20 mA and with the combined base emitter dropp of a Darlington is around 1.5 Volts. 3.5V / 0.02A = 175Ohms which would round up to a standard 180Ohm. You would have been ok with that or larger between your Arduino and the Darlingtons base. 20mA with gain of 300 to 1000 would allow 6 to 20 Amps to be controlled.

  32. Can I use 2N3904 transistor to control the motor?

    Although my circuit works with TIP120, I have to use a current limiter circuit. Could you please tell me how I can include a current limiter circuit. I used the circuit below, but when i connect the TIP120 output to the input below, my circuit does’nt work.

    http://www.physics.unlv.edu/~bill/PHYS483/current_lim.pdf

    Thanks for the video and your help in advance!

    1. The current limiter circuit shown in that link should work but you need to tailor the value of R1 to the current limit you want to set. The 14 Ohm resistor value will start to cause Q2 to conduct when the resistor has a current of 50ma. If you used a 0.33 Ohm power resistor instead it would allow about 2 Amps.

      The TIP 120 is a Darlington transistor. If you are using TIP120 for Q1 that will make some changes to the circuit. With the current limiter raising the Q1 emitter by 0.7 volts, and the fact that the Darlington will have 1.5Volts from base to emitter, your input signal needs to reach higher than 2.1 Volts at the Q1 base. This may or may not be an issue. If you have a 5 Volt input signal you should be fine. Even a 3,3 Volt input signal should be fine because the TIP120 has enough gain that 1kOhm across the remaining 1.2Volts, passing 1.2mA into the base will allow half an amp through the Q1 collector. Drop the R2 base input resistor value to 110 Ohms if you need more Q1 collector current.

  33. So we need to use an “if” function to be able to speed up a D/C Motor? Couldn’t we theoretically directly use analogWrite to whichever pin we wanted and have the D/C spin in that speed? Or am I missing some secondary code?

  34. Hello Jeremy

    I love you videos and always look at them for reference.

    My question is relating to how much load in mill amps can the Arduino Uno take on the +5 rail and how much of a load can the digital pin’s, analog pin’s take.

    Thanks

  35. I have the ladyada motor shield control and 2 two bigger ones which does not have servo pin connection.

    I was wondering if the servo motor would function properly if I connected it to the positive and negative pin for DC connection? Of course just using 2 wires.

    Thanks

    1. The Adafruit motor shield will run small bipolar steppers. http://www.ladyada.net/make/mshield/

      Check for their related library. http://www.ladyada.net/make/mshield/download.html

      It might be possible to adapt/convert from their schematic and library to use your larger motor shields.

      There are several types of stepper. Bipolar or Unipolar, with 2 or 3, or even 5 poles. Unipolar steppers can often be connected in a bipolar style.

      The operation of a stepper is brushless and depends on sequentially powering the coils. They require at least two coil power drivers for each motor. That is why steppers take both sides of the outputs that could drive two basic dc motors in the adafruit shield. The normal CoilACoilB bipolar AB sequence for full stepping with + and – to represent power polarity, will be something like ++,-+,–,+- .

      For the preferred microstepping control I will refer you to more detail than I can fit here.
      http://www.zaber.com/wiki/Tutorials/Microstepping

      1. hello jermy , would you help me please ?
        i want to stop the servo motor after rotating 90 degrees , and not allowing it to go back to possession 0
        is that possible ?
        and how ?

  36. hallo I am doing my final year project which involves sending pictures and sensor data to an ftp server using the sim 900 gprs shield for arduino which is something I am completely new at. I have used some codes from the internet and registered on free ftp server sites to send the data but i got no results I am not sure if i am doing everything write especially with the apn, IP and directory name configurations.

  37. Hello,
    my arduino mega2560 not providing sufficient out voltage
    I checked all digital pins and the problem is same.
    The pin output is 4.2-4.5V,and this output is not sufficient for my load.
    So, kindly tell me why is the cause of this reason and how to rectify it.
    (I don’t wont to use external amplifier circuits)
    Thank you.

  38. hi ,
    can you help me with some basic idea of arduino project with LCD, temperature sensor , light sensor and LED’s. I am totally stuck i have to submit it tomarrow. I was planing to make a model home in which i will turn the garden light on/off by detecting the intensity of light and will remotely control the room lights and with temprature sensor i will control the working of fan. I am having various chunks for the code but was unable to get them all together. Please help me

  39. Hi Jeremy,

    I would like to apply what you did here to a do motor controlled by a wii remote. This will power a electric longboard. Some questions I have are:
    1. Can I use the same pin you are using on the tutorial or will I have to use different ones since I am using Bluetooth to communicate to the controller?

    2. Is using the transistor a good idea when I am using a 22 v battery? I feel like it would fry the transistor; I am concerned about this because I don’t want the battery to fry my arduino.

    Thanks for all the awesome tutorials!

    1. If that pin is used by your bluetooth module, then just use another pin.

      Check the transistor datasheet, and see what voltage it is rated for. Most will handle 22V just fine – you should be more concerned about how much current you are running through it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Advertisement