Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
ESP8266 Robotics Projects

You're reading from   ESP8266 Robotics Projects DIY Wi-Fi controlled robots

Arrow left icon
Product type Paperback
Published in Nov 2017
Publisher Packt
ISBN-13 9781788474610
Length 210 pages
Edition 1st Edition
Tools
Concepts
Arrow right icon
Author (1):
Arrow left icon
 Seneviratne Seneviratne
Author Profile Icon Seneviratne
Seneviratne
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Writing Arduino sketch


You will need the following Arduino libraries to write the Arduino sketch to control two motors for detecting the track:

Listing 5-1 – Arduino sketch for line-following

Listing 5-1 shows a snippet from the complete Arduino sketch that you can use to upload to the Feather HUZZAH ESP8266 board. The complete code can be found in the example code file of this chapter:

#include "ESP8266WiFi.h" 
#include <Wire.h> 
#include <Adafruit_MotorShield.h> 
#include "sensorbar.h" //SparkFun line follower array Arduino library 
 
// Create the motor shield object with the default I2C address 
Adafruit_MotorShield AFMS = Adafruit_MotorShield();  
 
// And connect 2 DC motors to port M3 & M4 ! 
Adafruit_DCMotor *L_MOTOR = AFMS.getMotor(4); 
Adafruit_DCMotor *R_MOTOR = AFMS.getMotor(3); 
 
// Uncomment...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime
Visually different images