08.02.2023: 50 Ohm vs. 75 Ohm

15.02.2023: Dragino LA66 Shield

Elektronik | Funk | Software

Der Technik-Blog

  • Social Media


    New Posts

    The Tech-Blog

    Arduino Motorshield - How to controll a DC Motor

    Arduino DC Motor Control

    Alex @ AEQ-WEB

    There is also a video on YouTube for this article: Arduino DC Motor Controller - Motorshield

    The Arduino Motor Shield can be used to control servo, stepper and DC motors. Because multiple pins are used to control the driver, a library is recommended. Adafruit offers a good library, which is also compatible with non-original shields. For most shields, the first version is needed because the second version works only with i2c.  The software can control the Moter as with PWM signals from 0-255. The shield requires an external voltage supply for the motors, which must also be suitable for the motors. The Arduino gets the power from the shield.


    How the motor is controlled

    The shield can be used to control up to four DC motors. Each motor connection has two pins, depending on the direction of rotation (forward, backward) one of the pins has energy.  The ground-pin is always used by two motors. To allow a simple DC motor to rotate in both directions, the motor must be reversed. Beginners can reverse the motor with a relay-card.

    #include <AFMotor.h>
    AF_DCMotor motor(1); //Set Motor (1 = M1, 2 = M2, 3 = M3, 4 = M4)
    void setup() {
    void loop() {
      int i;; //FORWARD = PIN A / BACKWARD = PIN B
      motor.setSpeed(50); //Set motor speed

    Info: This page was automatically translated and may contain errors

    About the Author

    Alex, the founder of AEQ-WEB. He works for more of 10 years with different computers, microcontroller and semiconductors. In addition to hardware projects, he also develops websites, apps and software for computers.

    Top articles in this category:

    Arduino LM358 PT1000 Sensor Converter

    PT1000 Converter for Arduino

    • Video
    • DE/EN

    PT1000 sensors can not be measured directly analog with a microcontroller. How to build a PT100 Converter with LM358 and Arduino?

    read more
    Arduino LCD Interface - TFT Display Elegoo

    Arduino LCD Interface

    • DE/EN

    On this page we show you how to create an interface for a TFT display with an Arduino. You can download source code and library here

    read more

    Social Media


    New Posts