1.3 Turn the Wheel

A motor is a typical digital output device, and it is used in the same way as an LED. However, the motor needs to be driven with a large current, and the large current may damage the main control board such as R3 board. Therefore, an L298N module is used in this occasion, which is a good helper for the R3 board to control the motor safely.

Required Components

In this project, we need the following components.

It’s definitely convenient to buy a whole kit, here’s the link:

Name

ITEMS IN THIS KIT

LINK

3 in 1 Starter Kit

380+

3 in 1 Starter Kit

You can also buy them separately from the links below.

COMPONENT INTRODUCTION

PURCHASE LINK

SunFounder R3 Board

BUY

Jumper Wires

BUY

TT Motor

-

L298N Module

BUY

Schematic

../_images/circuit_1.3_wheel.png

IN1~IN4 are the inputs of the L298N module, and OUT1~OUT4 are the outputs.

A simple way to use them is: input high level for INx, OUTx will output high level; input low level for INx, OUTx will output low level. Connecting the two ends of the motor to OUT1 and OUT2, inputting opposite level signals for IN1 and IN2 will make the motor rotate. OUT3 and OUT4 can be used in the same way.

Wiring

L298N

R3 Board

Motor

12V

5V

GND

GND

IN3

9

IN4

10

OUT3

one wire of the motor

OUT4

one wire of the motor

../_images/turn_the_wheel_bb.jpg

Code

Note

  • You can open the file 1.3.turn_the_wheel.ino under the path of 3in1-kit\basic_project\1.3.turn_the_wheel.

  • Or copy this code into Arduino IDE.

  • Or upload the code through the Arduino Web Editor.