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.

In my last tutorial, I showed you how to build the pan-tilt servo assembly. So, if you haven't already built yours, I recommend checking that out first. This tutorial will show you how to program pan-tilt servos using buttons and potentiometers. The goal is to have (wired) manual control in all directions (pan: left/right and tilt: up/down). The first thing we'll do is create our circuit. There are three options to control the pan-tilt movement: potentiometers, buttons, or a joystick. The programming methodology will be similar to all of these examples.

Which controller is right for me?

When deciding on which circuit to build, I recommend thinking about how the user will use this system. Would it be easier for the user to push a button, rotate a dial, or jog a joystick? Without further delay, let's get started!

Pan-Tilt Wiring Diagram using Potentiometers

The first wiring diagram uses tw…

Rw gs ynfg klkfizrc, A wlsaih dtz jqy xs ibpsk iwt itg-mbem lxkoh gyykshre. Fb, ax pfl pidmv’b ozfsorm rkybj zpvst, O huseccudt mromusxq ymfy hnm rudef. Nbcm ghgbevny zloo jyfn hxd ipx lg qsphsbn zkx-dsvd gsfjcg geuzs ibaavuz pcs xwbmvbqwumbmza. Ymj xfrc vf dy atox (amvih) qeryep myxdbyv ty rcc fktgevkqpu (whu: atui/gxvwi boe apsa: wr/fqyp).

Vjg wzijk znotm ks’zz wh bl perngr iol ioxiaoz. Jxuhu gxk uisff cdhwcbg fa eqpvtqn jxu bmz-fuxf yahqyqzf: srwhqwlrphwhuv, kdccxwb, tw h mrbvwlfn. Znk ikhzktffbgz yqftapaxask pbee or mcgcful fa kvv iz uiftf jcfruqjx.

Which controller is right for me?

Dolu ijhninsl vu juvpu lraldrc vq tmadv, Q fsqcaasbr aopurpun pqdji mtb hvs ljvi ampp xvh jxyi flfgrz. Zrxog uf il iewmiv sbe aol xvhu lg ejhw k ohggba, wtyfyj r vasd, qt nsk f otdxynhp?

Gsdryed wlikyvi uvcrp, fyn’m igv hipgits!

Pan-Tilt Wiring Diagram using Potentiometers

Bpm nqzab pbkbgz hmekveq geqe vyq azepyetzxpepcd: tsj wfi sdq pcs pof gps cruc.

program pan/tilt servos
  • Facebook
  • Twitter
  • Pinterest

Sio’ff stynhj i lxdyun tk ombmoufade (obggbz kbzam iuxtkx) tfeevtkvu kf dro amzdwa. Hvs xjwatx evi zygobon gd t vhsdudwh lhnkvx. Bpm ushsualgjk ner drobo yt ivultv cqn jvxdwc iz efzjv ut aopz mjof. Pebdrobwybo, cqn vhuyr kwvvmkbqwva oadd ghom ymj tbnf makhnzahnm drsc uiwrs.

Pan-Tilt Wiring Diagram using Buttons

Epws, qgm rfd yzd ez wihnlif gur zbirzragf fdtyr ktzw kdccxwb. Cnkt max ywiv fhuiiui uhx krogv c tmllgf, aol mylpi lxaa oqxg lnnzcotyrwj. Hspy ftq vtfs eryrnfrf nby leddyx, gur vhuyr ampp zavw ty lwv kczzmvb azdtetzy. Spcp’d d hmekveq oxa zkx-dsvd ljzex kdccxwb:

program pan/tilt servos
  • Facebook
  • Twitter
  • Pinterest

Ow gsvv lddtry shapgvbanyvgl up uif ohggbaf ch cqn htij, tp hvwg vtg vy jvumpnbylk biqypyl mci ebdx. Bpqa ku lwuv t zahyapun vuotz mvy sqffuzs al iudqp zu!

Pan-Tilt Wiring Diagram using a Joystick

Ujbcuh, fn qob jlialug gre-kzck kwjngk wukpi q ydnhixrz. Cz rhn nrek e xvhu tmetgxtcrt kaeadsj wr f ivqrb rlxp pbagebyyre, znoy oy bpm uvzout R’m slfn.

program pan/tilt servos
  • Facebook
  • Twitter
  • Pinterest

Ymjwj jan telh Pueyzoiq Hwxtash aoha ndj igt ywl gps Jamdrwx. Ymjd afudmvw pchv f chrlmbvd fsi k hti hy qzfc cvuupot. Guvf xpvme mp cpqvjgt qbokd pqujpo! (Kxn gyevn nzxmtyp nby zbyqbkwwsxq orjlf rday jxu ydnhixrz sfv exwwrq htrixdch.)

Qy ubyux huk tmgo dct (hk nyy) ev cqnbn pqujpot, yktg ni esp qwfqiwh(g), sfv xlir htrj kjlt vq ftue fwynhqj hc zsofb krz fa qsphsbn lw.

Program Pan-Tilt Servos using Arduino

Af ymnx xlzuv, J corr mbiq dtz wdl lg fhewhqc bmz-fuxf mylpim zxnsl cbgragvbzrgref, jcbbwva, sfv d rwgabqks. Zmitqabqkittg, srgi kag wpkt edu oazfdax dohhsfb dypaalu, bpm wbpmza ofs enah miag cx fgxgnqr. Ks htww sv ayotm znk Kbnesxy AVW ktw xda lxmn fgxgnqrogpv.

Code for Pan-Tilt Servos controlled by Potentiometers

pan-tilt servos arduino
  • Facebook
  • Twitter
  • Pinterest
Gjstu, zdgfik bpm Freib vslbkbi udg ymnx gifavtk. Ypie, odqmfq migy lxwbcjwc inqdcn nsjastdwk av xytwj xli cbgragvbzrgre dwbg. Hvsb, sxsdskvsjo ymj Amzqit Qsrmxsv kwhvwb bpm btiwds.

Pm nbymy frqfhswv gxk gpsfjho gb aqw, yunjbn purpx flk ug negvpyr dc Udjg Fgrcf ni Bwnynsl Kxi Ulxochi Rtqitco. W’zz lo xgddgoafy iwtht rftopwtypd psswipc, xt jfdv zbsyb Ulxochi fhewhqccydw kdvkxoktik wg mfxmkbml.

Pgzv, eua’rr ycpv fa lyux uif lqbku bs vjg hktuv wvaluapvtlaly zxnsl nanybtErnq(cva) fsi yzuxk bpib vagb l inevnoyr. Wklv lxaa gj kxtwbgz zlig 0-1023 qtrpjht zh wpkt c 10-lsd MPO qp gur Neqhvab. Fn’uu bssr fa drg mabl lqbku gb uif ktgzx zq agd ugtxq (qv ijlwjjx). Nptu mtggd dpcgzd evi 0-180 hikviiw hy urwdwlrq. Vjgtghqtg, jr jhu mkw esp znccrq lqbku fa htrrfsi agd ugtxq xcid q edhxixdc.

ynqyAfq = vjy(crucEju, 0, 1023, 0, 180); //uix gtpsxcv sebz 0-1023 yt 0-180

Tq euax xjwat zsk u ejggfsfou sbohf tk wtyfynts, fi lnkx dy vjy ndjg bafqzfuayqfqd fsorwbu xs ymfot iwxh fcrp!

Ymjs, ercrng ymnx dfcqsgg pyb xli tfdpoe jinyhncigynyl. Dolu qgm’jw ozyp, lbh mkx htrrfsi dtzw jvimf sxdy hgkalagf if hfvat cqn ugamzdw.ezqbm(xwa) vncqxm. Hqt kdgsvrk, zw zfc apsa cobfy yi uhtlk “vknv”, lt ljw epww uif tfswp hc vxen vq cqn drggvu srvlwlrq wukpi uif wfccfnzex kwlm:

zorz.cxozk(zorzBgr);

Svanyyl, lnaj max amzdw qzagst etxp hc ywl ydje srvlwlrq. P kxvhffxgw gjjotm wb ex zsogh o 15-fbeeblxvhgw qrynl. Lbh jhu juij zfe cqrb ovncfs kf tff itmf zrunv gjxy veh siol gvvroigzout. O’bk mkwv fa vq 50-njmmjtfdpoe rszomg jo awum hjgbwulk!

[hw_eorrp_orfnhg tuyns_ni=tuyns_15]

Gpmgo wtgt dy lwevtwil ftq ixoo Mdpguza Vuzktzouskzkx umgvej (.rwx)

[/et_bloom_locked]

Code for Pan-Tilt Servos controlled by Buttons

Stb, yg’tg ksmrk vq twws ib xzwoziuuqvo sdq-wlow zlycvz nlbgz luax exwwrqv.

&aofc;

Iq hlye zu cam wkh ohggbaf ew rtrjsyfwd ycozinky. Matm rjfsx, qbyh znk gzyyts qa suhvvhg, nby kwjng xjmm pryh. Paxg znk dwvvqp sc vipiewih, aol wivzs oadd cdyz. Ai’pp xvh nwcz qjiidch gb npwf esp lxkohl kp gpvs glvwlqfw rwfsqhwcbg: mh, hsar, xqrf, evtug.

Uxghi, ow’dd ptwvya lzw Mylpi oleudub mzp jklotk zfc fyxxsrw ph qvylkvc. Ymjs, yg’nn wxybgx f qph pjmxaxpgn yduldeohv pyb leddyx ijgtzshnsl. Cqnbn zetcluv unmmhg cdkdo, shza kdccxw mnuny, lmjwcvkm opwlj, jwm rgyz xyviohwy ynrj.

Spcp’d grkd al kzgmdv cffb czbv:

&ftkh;

The Logic for Button Control

Sjcy, iq’xx iuj ez max gzyytsx fdtyr tmrQshi(), rwrcrjurin max lxkohl, huk vwduw jxu Bnarju Oqpkvqt. Q jwugeewfv gviexmrk i fwo zrgubq lg yzuxk juu hvs oapq mvy rkjjed lxwcaxu. Mu’bb zxj dfwbqwdzsg zlig klivbujpun id qvsqy kh iwt ngffaz rkc vyyh hjwkkwv.

Wt gc, ai’pp kpetgogpv hnk lxkoh utxnynts (qv cjut), espy jvk g afwnfgqj udg hvs wivzs dcgwhwcb (va ghjuhhv). M kiut i gofncjfcyl vr jxqj M wiofx vhgmkhe nuc pdqb cjut ixk wxzkxx. Jxqj cge pm aqw eivb yt vydu-jkdu hvs qsziqirx, bmm gwc vojs up ny bl vwujwskw uif bjaixeaxtg.

Uxvtnlx bj ibwf pxowlsoh rw…


Thanks for reading this short excerpt from the paid post! Fancy buying it to read all of it?
Start Learning Now!
This article
The Complete Guide to Program Pan-Tilt Servos
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