Using Arduino and l298n (red Board) to drive DC motors

Source: Internet
Author: User

l298n Introduction

l298n Drive module, can drive 2 DC Motor , can be used to achieve positive turn , reverse function.



BOM List

Arduino Uno * 1
l298n Drive Module * 1
DC Motor * 2
9v Battery * 1
Jumper several


Arduino Uno + l298n driver module wiring




Note: If the voltage is not enough , the motor may not turn oh, so to external 7v-12v power.

Program source code to upload the program to the motherboard, connected to the external power supply, the motor will turn up.
Here the IO port is selected as 5,6,9,10, which are all fourSupportPWM, which can be achieved through the duty-free codeControlTurnSpeedThe speed.
-------------------↓ You can press this button to copy the code-------------------↓
Lingshun Labint input1 = 5; Defines a UNO pin 5 to input1 output int input2 = 6; Defines a UNO pin 6 to input2 output int input3 = 9; Defines a UNO pin 9 to input3 output int input4 = 10; Define UNO pin 10 to input4 output void Setup () {//  Serial.begin (9600);//Initialize each IO, mode output mode Pinmode (Input1,output); Pinmode (input2,output);p Inmode (input3,output);p Inmode (input4,output);} void Loop () {  //forward forward  digitalwrite (Input1,high);//Give High Level  digitalwrite (input2,low);  Give low Level  digitalwrite (Input3,high);//Give High Level  digitalwrite (input4,low);  Give low  -level delay (+)   ; Delay 1 seconds//stop stop digitalwrite (Input1,low); Digitalwrite (input2,low);   Digitalwrite (Input3,low); Digitalwrite (input4,low);   Delay (+);  Delay 0.5 seconds    //back backward turn  digitalwrite (input1,low);  Digitalwrite (Input2,high);    Digitalwrite (input3,low);  Digitalwrite (Input4,high);    Delay (+);    }


Drive DC motor using Arduino and l298n (red Board)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.