Experiment of controlling the moving direction and the speed of the 4-wheel smart car

Experiment of controlling the moving direction and the speed of the 4-wheel smart car

In this article we will explain how to control the 4-wheel smart car to go forward and backward, turn left and right. We can refer to the manual https://www.adeept.com/learn/detail-4.html to connect the wiring of the car.

``````/***********************************************************
Description:

Author: Tom
Date: 2019/03/04
***********************************************************/
#include <Servo.h>

Servo dirServo;                   // define servo to control turning of smart car
int dirServoPin = 2;              // define pin for signal line of the last servo
float dirServoOffset = 0;         // define a variable for deviation(degree) of the servo
int dirServoDegree;

const int dirAPin = 7;    // define pin used to control rotational direction of motor A
const int pwmAPin = 6;    // define pin for PWM used to control rotational speed of motor A
const int dirBPin = 4;    // define pin used to control rotational direction of motor B
const int pwmBPin = 5;    // define pin for PWM used to control rotational speed of motor B

#define FORWARD HIGH
#define BACKWARD LOW

void setup() {
dirServo.attach(dirServoPin);  // attaches the servo on servoDirPin to the servo object
pinMode(dirAPin, OUTPUT);   // set dirAPin to output mode
pinMode(pwmAPin, OUTPUT);   // set pwmAPin to output mode
pinMode(dirBPin, OUTPUT);   // set dirBPin to output mode
pinMode(pwmBPin, OUTPUT);   // set pwmBPin to output mode
}
void loop()
{
dirServoDegree = 90;
int motorSpd = 200;
bool motorDir = motorSpd > 0 ? FORWARD : BACKWARD;
motorSpd = abs(constrain(motorSpd, -512, 512));
motorSpd = map(motorSpd, 0, 512, 0, 255);
// control the steering and travelling of the smart car
ctrlCar1(dirServoDegree,motorDir, motorSpd);
}
void ctrlCar1(byte dirServoDegree, bool motorDir, byte motorSpd) {
dirServo.write(dirServoDegree + dirServoOffset);
digitalWrite(dirAPin, motorDir);
digitalWrite(dirBPin, motorDir);
analogWrite(pwmAPin, motorSpd);
analogWrite(pwmBPin, motorSpd);
}``````

Now we give you the explanation of the code.

1. To control the servo of the car, you need to use the servo control function. Add the header file of the servo control function at the beginning of the code.
``#include <Servo.h>``

After adding the header file, you need to set which port of the UNO the servo is connected to and the servo angle, the code is as follows:

``````Servo dirServo;                   // define servo to control turning of smart car
int dirServoPin = 2;              // define pin for signal line of the last servo
float dirServoOffset = 0;         // define a variable for deviation(degree) of the servo
int dirServoDegree;``````

Next we need to add the function of the initialization configuration in the function initialization (setup()), as follows:

``dirServo.attach(dirServoPin);  // attaches the servo on servoDirPin to the servo object``

Then modify the value of dirServoDegree in the loop() function to control the motion direction of the servo. The input range of dirServoDegree is 0~180.

``dirServoDegree = 90;``

Finally, we add the following function to “ctrlCar1”.

``dirServo.write(dirServoDegree + dirServoOffset);``

Then we can control the rotation angle of the servo.

1. Control the speed at which the car moves forward and backward. First we need to define the port where UNO controls the operation of the motor. The definition function is as follows:
``````const int dirAPin = 7;    // define pin used to control rotational direction of motor A
const int pwmAPin = 6;    // define pin for PWM used to control rotational speed of motor A
const int dirBPin = 4;    // define pin used to control rotational direction of motor B
const int pwmBPin = 5;    // define pin for PWM used to control rotational speed of motor B``````

Next add the function of initialization configuration in the initialization function (setup()).

`````` pinMode(dirAPin, OUTPUT);   // set dirAPin to output mode
pinMode(pwmAPin, OUTPUT);   // set pwmAPin to output mode
pinMode(dirBPin, OUTPUT);   // set dirBPin to output mode
pinMode(pwmBPin, OUTPUT);   // set pwmBPin to output mode``````

Then we can modify motorSpd to control the speed and direction of the car. The input range of this function is -512 to 512. When the speed value is negative, the car goes backward, and when the speed value is positive, the car goes forward.

``````     int motorSpd = 200;
bool motorDir = motorSpd > 0 ? FORWARD : BACKWARD;
motorSpd = abs(constrain(motorSpd, -512, 512));
motorSpd = map(motorSpd, 0, 512, 0, 255);
// control the steering and travelling of the smart car
ctrlCar1(dirServoDegree,motorDir, motorSpd);``````

1,965 Replies to “Experiment of controlling the moving direction and the speed of the 4-wheel smart car”

1. Pingback: toto tribe upsc
2. Pingback: online casino app
3. Pingback: online casino
4. Pingback: slot game online
5. Pingback: p4 solution bank
6. Pingback: online classes app
7. Pingback: alibaba
8. Pingback: pcb electronics
9. Pingback: exante xnt
10. Pingback: runaway lyrics
11. Pingback: runaway song
12. Pingback: bali digital
14. Pingback: uk tech news logo
15. Pingback: online casino goa
16. Pingback: can dogs eat sago
17. Pingback: slots online free
18. Pingback: qq999 slot
19. Pingback: bitboy crypto wife
20. Pingback: slot terbaru
21. Pingback: save shopping
23. Pingback: agen judi bola
24. Pingback: celebrity news ok
25. Pingback: diy helium miner
26. Pingback: mntd helium miner
27. Pingback: real estate agent
28. Pingback: nclex tutor online
29. Pingback: baccarat vase
30. Pingback: red dog casino
31. Pingback: laurie eisenberg
32. Pingback: result hk tercepat
33. Pingback: gazete keyfi spor
34. Pingback: gazeteler net
35. Pingback: free website
36. Pingback: kyk hydrogen water
37. Pingback: argo casino
39. Pingback: pragmatic88
41. Pingback: casino bet online
42. Pingback: layarindo21 fun
43. Pingback: joker123 myanmar
44. Pingback: water dispenser ro
45. Pingback: g2g new world gold
46. Pingback: joker gaming 777
47. Pingback: slot 123
48. Pingback: slot gacor
49. Pingback: joker123 myanmar
52. Pingback: joker123 myanmar
54. Pingback: joker123 myanmar
55. Pingback: joker123 myanmar
56. Pingback: joker388
57. Pingback: Shopping
58. Pingback: spartan poker
59. Pingback: igm247 bonus
60. Pingback: online movies
62. Pingback: maxbet india
63. Pingback: kapal slot4d
64. Pingback: fibromyalgia uk
67. Pingback: asylum stresser
68. Pingback: joker123 png
69. Pingback: daftar qq online
70. Pingback: types of biography
71. Pingback: comedy movies
72. Pingback: rich water bottle
73. Pingback: rich water brands
74. Pingback: yola website
75. Pingback: cute axolotl
81. Pingback: best slots to play
82. Pingback: agen slot
83. Pingback: g2g new world
84. Pingback: 888 poker
85. Pingback: online games
86. Pingback: mx player movies
87. Pingback: cmd77
88. Pingback: mpo888
89. Pingback: judi bola parlay
90. Pingback: ac service in usa
91. Pingback: bandarqq pkv
92. Pingback: ruay98
93. Pingback: cmd slot
94. Pingback: cmd slot
95. Pingback: essay service
96. Pingback: slots casino
97. Pingback: kaftan dress top
98. Pingback: filmapik21
99. Pingback: masterslot88
100. Pingback: agen cmd368
101. Pingback: epic games store
102. Pingback: best online slots
103. Pingback: slot meaning
104. Pingback: online slots uk
107. Pingback: live casino online
108. Pingback: online casino goa
109. Pingback: a
110. Pingback: maxbet bih
111. Pingback: maxbet app
113. Pingback: online casino goa
114. Pingback: new online slots
115. Pingback: online casino
116. Pingback: joker388
117. Pingback: ae gamer
118. Pingback: situs pkv games
119. Pingback: sa gaming
120. Pingback: best inc. usa
121. Pingback: online toto sports
122. Pingback: safe toto site
123. Pingback: dewa slot 88
125. Pingback: joker123 apk
126. Pingback: cisco exam booking
127. Pingback: pmp dumps
128. Pingback: bpc-157 reddit
129. Pingback: free movies cinema
131. Pingback: bee farm florida
132. Pingback: football soccer
133. Pingback: garden sprayer
134. Pingback: pkv games
135. Pingback: sbobet games
136. Pingback: dewabet malaysia
137. Pingback: swindon
139. Pingback: bukakunci 7meter
140. Pingback: 7meter win
141. Pingback: greetings island
142. Pingback: play lotto online
143. Pingback: is virtru free
144. Pingback: water air purifier benefits
145. Pingback: ionizer air purifier price
146. Pingback: best car air purifier for covid
147. Pingback: air purifier manufacturers in india
148. Pingback: best desktop air purifier 2021
149. Pingback: air purifier tower in india
151. Pingback: joker123 png
152. Pingback: slots online free
153. Pingback: poker online
154. Pingback: tangkas xyz
155. Pingback: afyon population
156. Pingback: betway app
158. Pingback: live casino online
159. Pingback: stars77
162. Pingback: magento marketplace
163. Pingback: slots online free
165. Pingback: sbobet88 asia
167. Pingback: useful site
168. Pingback: qq poker online
171. Pingback: joker123 agent
172. Pingback: dating sites free
173. Pingback: ar15 magazine
175. Pingback: sbobet asia
176. Pingback: dewa89 slot
177. Pingback: pkv games
178. Pingback: portraits
181. Pingback: best online poker sites for real money
182. Pingback: 888 poker new software
183. Pingback: online gambling in india legal
185. Pingback: casino games online
186. Pingback: free online slot machines
187. Pingback: essay writing websites
188. Pingback: types of lawyers in india
189. Pingback: livescore.mobi 24
190. Pingback: best essay writing service free
191. Pingback: best essay writing service
192. Pingback: finance degree
193. Pingback: free full movies
194. Pingback: legal online gambling sites
196. Pingback: c5-c6 disc herniation symptoms
197. Pingback: sildenafil 100mg
198. Pingback: microsoft office 2021 preview
199. Pingback: sildenafil 100mg
200. Pingback: situs slot online
201. Pingback: pragmatic88
202. Pingback: free online games
204. Pingback: king maker kamaraj
205. Pingback: result lotto
206. Pingback: mega888 apkpure
207. Pingback: 9king
209. Pingback: best free online casino slot games
210. Pingback: write my essay
212. Pingback: Visit
213. Pingback: Go to
216. Pingback: cuckoo disinfectant solution generator reviews
217. Pingback: sbobet asia
218. Pingback: boat for rent nasugbu
219. Pingback: online casino real money india
220. Pingback: sbobet 777
221. Pingback: sbotop logo
222. Pingback: dashiki shirt meaning
223. Pingback: african head wraps styles
224. Pingback: kente cloth origin
225. Pingback: dashiki shirt near me
226. Pingback: zivame swimwear
227. Pingback: afrofuturism history
228. Pingback: doll swimwear
229. Pingback: afrofuturism music
230. Pingback: smoking gun game
231. Pingback: is epal.gg safe
232. Pingback: digital marketing agency usa
233. Pingback: accounting subject
234. Pingback: disinfectant generator spray
235. Pingback: photography types
236. Pingback: bigsloto
237. Pingback: bigsloto
238. Pingback: weathertech garage floor mats
239. Pingback: solar deck lights walmart
240. Pingback: where to find solar christmas lights
241. Pingback: freebet site
242. Pingback: specialty chemicals industry news
243. Pingback: joker123 agent
244. Pingback: sbobet mobile web
245. Pingback: watchseries1
246. Pingback: free tv shows website
247. Pingback: kitchen equipment near me
248. Pingback: mojobet
249. Pingback: online furniture stores india
251. Pingback: joker123 website
252. Pingback: us air purifiers
253. Pingback: levels of cleaning and disinfection
254. Pingback: all-in-one business management software free
255. Pingback: best football live streaming sites free
257. Pingback: football game
258. Pingback: rove pen
259. Pingback: big chiefs
260. Pingback: football live 2021
261. Pingback: dewalive daftar
262. Pingback: ignition poker
264. Pingback: online gambling in india legal
265. Pingback: what is slot online
266. Pingback: kapaljudi
267. Pingback: indoxxi terbaru
268. Pingback: scbet88
269. Pingback: food clean machine
270. Pingback: spray sanitizer
271. Pingback: coway air purifier
272. Pingback: panen138
273. Pingback: rumah bola88
274. Pingback: free online casino
275. Pingback: idn poker 88 pulsa
276. Pingback: air ionizer india
277. Pingback: kokoqq
279. Pingback: tokyo slot888
280. Pingback: asian poker rules
281. Pingback: 1 gram of moonrock
282. Pingback: rjr prop money
283. Pingback: runtz seeds
284. Pingback: white runtz
285. Pingback: situs slot 555
286. Pingback: app club games
287. Pingback: register joker123
288. Pingback: what is blockchain
289. Pingback: bitcoin to dollar
290. Pingback: robotics examples
291. Pingback: joker123 website
292. Pingback: televicentro
293. Pingback: toto casino
295. Pingback: bandarq pkv
296. Pingback: voc filter meaning
297. Pingback: bandar sakong
298. Pingback: pm 2.5 map
299. Pingback: mariobola
300. Pingback: sarms supplement
301. Pingback: cnc wood router
302. Pingback: scbet88
303. Pingback: pusatqq
304. Pingback: rajawaliqq
305. Pingback: langitqq
306. Pingback: sports newscricket
307. Pingback: nile cruises 2021
308. Pingback: live stream
309. Pingback: live stream
310. Pingback: live sports tv
311. Pingback: lottoland
312. Pingback: 1xbet casino
313. Pingback: lk21 website
314. Pingback: snooze off meaning
315. Pingback: bandarqq365
316. Pingback: bandarqq88
318. Pingback: white runtz
319. Pingback: movie prop money
320. Pingback: glock 19 gen 5
321. Pingback: air purifier argos
322. Pingback: air cleaner
323. Pingback: online casino
325. Pingback: freebet number
326. Pingback: glide design
328. Pingback: glock 19 holster
329. Pingback: mann filter india
330. Pingback: airfilterusa
331. Pingback: honey extension
332. Pingback: Feedback
333. Pingback: best iptv app 2021
334. Pingback: iowa ask a lawyer
336. Pingback: new homes for sale
337. Pingback: gambling sites
338. Pingback: best rv for sale
339. Pingback: toto india
340. Pingback: get it now}
342. Pingback: free goats near me
343. Pingback: Get it here
344. Pingback: file manager
345. Pingback: product branding
346. Pingback: shibori tie dye
347. Pingback: bet soccer team
348. Pingback: Get IT Support
349. Pingback: get clean air
350. Pingback: check out this
351. Pingback: situs judi kartu
352. Pingback: find now
353. Pingback: crowdfund republic
354. Pingback: airfree tulip 80
355. Pingback: www u16822
356. Pingback: nifty's nft
357. Pingback: idn texas poker
358. Pingback: bigsloto
359. Pingback: poker online
360. Pingback: search anything
361. Pingback: w88 malaysia
362. Pingback: prop money near me
363. Pingback: vlone runtz strain
365. Pingback: auto pg slot
366. Pingback: lava slot 888
367. Pingback: sports369 togel
368. Pingback: benefits of weeds
371. Pingback: judi bola
372. Pingback: sbobetasia wap
374. Pingback: free online tools
375. Pingback: bulk sms marketing
376. Pingback: viagra 100
377. Pingback: kamagra 100mg
379. Pingback: sbobet makati
380. Pingback: pg slot myanmar
381. Pingback: gd lotto app
382. Pingback: pasaran hk pools
383. Pingback: slot jokerbet303
385. Pingback: mmojugg
386. Pingback: bonus bursa303
387. Pingback: sa gaming88
388. Pingback: slot online free
389. Pingback: celebrity bakery
390. Pingback: fafa855 slot

Here at Leslie’s Pugsland Breeder, Our beautiful fawn pug has given birth to 4 healthy Pug puppies.
She is our beloved family dog and this is her 1st litter.
Both mum and dad are AKC registered with 5 gen pedigree certificate. Both from Top Champion bloodlines.Mum and Dad can be seen. Puppies have been wormed weeks 2,4,6,8 and will have had a flea preventative treatment before leaving us.
They will have their vet check, 1st vaccinations and microchip.
To view all available puppies and recent pictures, Search us in google as LESLIE’S PUGSLAND BREEDER or click on our website link bellow : https://pugslandbreeder.company.com/

Pug Puppies for sale | pug for sale near me | pug puppy for sale | pug puppy | pug for sale | pug puppies for sale in va | black pug puppies for sale

392. Pingback: pokercc77
393. Pingback: pokercc asia
395. Pingback: domino qiu qiu apk
396. Pingback: k2researchchems
397. Pingback: judi slot booming
398. Pingback: Oxycodone pills
399. Pingback: pkv games
400. Pingback: sbobet register
401. Pingback: Shop It
403. Pingback: olansi group
404. Pingback: sports news
405. Pingback: olansi alibaba
406. Pingback: oem air purifier
407. Pingback: oem air purifier
408. Pingback: k08 air purifier
410. Pingback: k08 air purifier
412. Pingback: Find goats here
413. Pingback: Visit Here
414. Pingback: best nepal tour
415. Pingback: glock 19 gen 5
416. Pingback: bitcoin price
418. Pingback: china mold makers
420. Pingback: situs judi
422. Pingback: beer777 sbobet
423. Pingback: olansi group
424. Pingback: pkv judi qq
425. Pingback: nurse prose review
426. Pingback: olansi global
427. Pingback: olansi group
430. Pingback: olansi group
431. Pingback: olansi alibaba
432. Pingback: k08 air purifier
433. Pingback: olansi group
434. Pingback: Judi Poker Online
435. Pingback: pomeranian white
436. Pingback: olansi global
437. Pingback: olansi group
438. Pingback: ip camera viewer
440. Pingback: prop money near me
441. Pingback: k08 air purifier
442. Pingback: kiukiu
443. Pingback: real pink runtz
444. Pingback: olansi k08a
445. Pingback: croma air purifier
446. Pingback: oem air purifier
447. Pingback: vintage kilim rugs
448. Pingback: pubg diamond hack
450. Pingback: cavapoo full grown
451. Pingback: olansi k08a
452. Pingback: jeremy hughes hsbc
453. Pingback: what is nembutal
455. Pingback: floor marking tape
456. Pingback: Go to This Website
457. Pingback: Taylan Evrenler
458. Pingback: bloom vape battery
459. Pingback: daftar slot online
460. Pingback: singapore pools
461. Pingback: Visit Here
462. Pingback: Skin Care Products
463. Pingback: sollift machine
464. Pingback: today news bihar
465. Pingback: ceriabet
467. Pingback: Golf cart battery
468. Pingback: cbd oil uses
469. Pingback: webm to.mp4 api
470. Pingback: photo funny love
471. Pingback: bvlgari ring price
472. Pingback: off white edibles
473. Pingback: cbd oil
474. Pingback: royal funny status
475. Pingback: screw kit for pc
476. Pingback: cam lock screws
477. Pingback: self locking screw
478. Pingback: world globe price
479. Pingback: world globe price
480. Pingback: ev battery cell
481. Pingback: cheese price
482. Pingback: best online casino
483. Pingback: online casino
484. Pingback: cbd products
485. Pingback: dominoqq apk
486. Pingback: howto site
487. Pingback: 100% free essays
489. Pingback: ev12-180x battery
490. Pingback: write articles
491. Pingback: media files
492. Pingback: mp4 converter
493. Pingback: mp3 converter app
494. Pingback: pepperfry
495. Pingback: sot gambling site
496. Pingback: virtual visa card
497. Pingback: vaping aerosol
498. Pingback: layar kaca 21
499. Pingback: cassino online
500. Pingback: live casino online
501. Pingback: judi bola 88
502. Pingback: gout definition
503. Pingback: get scholarship
504. Pingback: 888 casino
506. Pingback: dog care website
507. Pingback: sheet mask at home
508. Pingback: poker stars
510. Pingback: list of anime
511. Pingback: buy osrs gold safe
513. Pingback: anime tv
515. Pingback: goa casino online
516. Pingback: Find food for pet
518. Pingback: lightsaber toy
520. Pingback: best pet food
521. Pingback: pyrenees spain
522. Pingback: lip balm himalaya
523. Pingback: home cash app
524. Pingback: dark web browser
525. Pingback: healthy food
526. Pingback: dewa4dku
527. Pingback: pandora188
528. Pingback: win88
529. Pingback: Microswitch
530. Pingback: mini-limit switch
532. Pingback: Testing57
533. Pingback: Testing56
534. Pingback: Testing 55
535. Pingback: Zastave Arms CZ999
536. Pingback: sahabatpoker
537. Pingback: hondaqq
538. Pingback: official site
539. Pingback: tutoring online
540. Pingback: homework helper
541. Pingback: THC Carts for sale
543. Pingback: Dylan Sellers
544. Pingback: tor web pages
546. Pingback: care credit
547. Pingback: sex toys
548. Pingback: m88 bi chan
549. Pingback: mansion88
550. Pingback: lesbian strapon
551. Pingback: keluaran hk pools
552. Pingback: rajapoker88
553. Pingback: DotNek Tech Blog
554. Pingback: CBD Spray
555. Pingback: 21 dukes
556. Pingback: bitcoin price
557. Pingback: debian vpn
558. Pingback: togel seoul
559. Pingback: ufabet
560. Pingback: more
561. Pingback: Car Rental Deals
562. Pingback: seo cambridge