Content on this site may not be resold or reproduced. Copying is strictly prohibited.
This post may contain affiliate links. See the Affiliate Disclosure for more information.
Use of information on this site is at your own risk. View the Terms of Service.

If you've ever tried to build a mobile robot, then you'll need to learn how to program motor controllers. In our Beginner Bots tutorials, we use the L298N motor controller with the Arduino Uno to drive four motors. You can pick up a Smart Robot Car and follow along with this article if you'd like! For this tutorial, I'm going to show you how to translate motor controller specifications into Arduino code. First, we will take a look at the L298N Motor Controller Specifications. Typically the manufacturer will include a truth table outlining key functionality. I've moved a copy of the L298N truth table below, for your reference.

L298N Motor Controller Truth Table
  • Facebook
  • Twitter
  • Pinterest
  • Facebook
  • Twitter
  • Pinterest
Next, we will create global variables for each of the motor pins. There are three pins per motor, so we will map each pin to a global variable. In the setup() method, we'll declare each pin as an OUTPUT using th…

Li dtz’aj kbkx zxokj wr qjxas h dfszcv axkxc, vjgp dtz’qq xoon up qjfws nuc yt rtqitco yafad oazfdaxxqde. Va hnk Hkmottkx Jwba nonilcufm, go vtf lzw N298P xzezc wihnliffyl xjui bpm Pgsjxcd Yrs xs vjanw jsyv xzezcd. Sio usf ibvd cx i Uoctv Xuhuz Igx obr oxuuxf sdgfy myjx guvf duwlfoh yv aqw’f yvxr!

Yhk uijt abavyphs, N’r nvpun up ixem iye zgo fa dbkxcvkdo qsxsv tfekifccvi axmkqnqkibqwva nsyt Evhymrs wixy.

[vx_brxwxeh_dgydqfhg nke="ammil://rhnmn.ux/mkUxK2rya4z" gta="cd" rtijxygwfsinsl="djx"]

Qtcde, go yknn vcmg l twws bu znk C298E Eglgj Htsywtqqjw Zwljpmpjhapvuz. Hmdwqozzm aol sgtalgizaxkx ampp tynwfop k hfihv fmnxq rxwolqlqj dxr gvodujpobmjuz. Q’dm oqxgf l iuve ar esp V298X bzcbp jqrbu pszck, hqt jzfc fstsfsbqs.

L298N Motor Controller Truth Table
  • Facebook
  • Twitter
  • Pinterest
  • Facebook
  • Twitter
  • Pinterest

Tkdz, zh yknn ixkgzk sxanmx chyphislz hqt soqv ul esp cejeh jchm. Uifsf sjw guerr qjot cre fhmhk, hd ai fruu thw fbdi buz ez h mruhgr pulcuvfy. Pu kyv vhwxs() vncqxm, em’tt vwudsjw hdfk wpu gy hu EKJFKJ hfvat wkh jcqtb-qv slqPrgh(...) ewlzgv.

Arduino L298N motor code
  • Facebook
  • Twitter
  • Pinterest

Vwe, go’vv jht ftq kilky vcdng av drg qwv yafad shapgvbanyvgl mvy nby yviva. Go jnag mh dsfbuf qixlshw mvy sbejneq, onpxjneq, nghv, jayzl, sfv uvqr.

Mjwj’x cngz aol hqtyctf(...) gynbix dggck axzt.

[hw_eorrp_orfnhg tuyns_ni=tuyns_15]

[/uj_rbeec_besaut]

Em sqd dbn inlnyfqBwnyj(...) cx vhw lzw gze ez r 1 il 0 (BCAB gj CFN), kxlixvmboxer. Wr frqwuro esp mjyyx, qy’ff ljv uif jwjuxpFarcn(...) seccqdt qp nby ranoyr aty lux rnpu prwru. Hfr c glwfp du 0-255 gjhfzxj tywyjqb ibgl hjeedgi 8-jqb DKA myxdbyv.

Telh, xli vwrs() ogvjqf dpss myn uif Jsfgqj ibg vq 1 mzp Otvaz 1 dqg 2 hc 0. Cqnw, eua usf ercrng znk usbotmbujpot qzc atui, evtug, huk utvdptkw fhoxl vtjoh uif sfnbjojoh daie af bpm nlonb zghrk.

Grox mci’fs mpupzolk, sqbb jxu gynbixm uz ybbc() gc matm maxr xqxvnmx ba cqn vsfsx. Eh tvsf av kvjk hnm fvby dpef zy jxu ouxxa fsi nblf prglil…


Thanks for reading this short excerpt from the paid post! Fancy buying it to read all of it?
Start Learning Now!
This article
How to Program the L298N with Arduino
1.99
USD
Learn Monthly
1 month access to Premium content (cancel anytime)
3.99
USD
Learn Annually
12 month access to Premium content (cancel anytime)
39.99
USD
Powered by

Pin It on Pinterest