Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Arduino Robotic Projects
  • Table Of Contents Toc
  • Feedback & Rating feedback
Arduino Robotic Projects

Arduino Robotic Projects

By : Richard Grimmett
4.3 (10)
close
close
Arduino Robotic Projects

Arduino Robotic Projects

4.3 (10)
By: Richard Grimmett

Overview of this book

Table of Contents (21 chapters)
close
close
Arduino Robotic Projects
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
1
Index

Controlling the servos with a program


Now that the hardware is connected, you'll need to supply the control signal to make your servos move. To control your servo, bring up the Arduino IDE. Make sure that the proper Arduino and port are chosen. Then enter the lines of code as shown in the following screenshot:

This code uses the Servo library that is installed with the standard Arduino IDE. The three sections of code that you'll need to understand are as follows:

  • The global variables servo, servoPin, and angle are used by the program. The Servo data type adds a set of functions so that you can control your servo. This includes the servo.attach(servoPin) and servo.write(angle) functions, which you will use in this program to send the servo to a specific angle. To find out all the different functions that are available, visit http://arduino.cc/en/reference/servo.

  • The setup() function connects the servo functionality to the proper pin and then initializes the serial port.

  • The loop() function reads...

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Arduino Robotic Projects
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon