Project 5: Ultrasonic Sensor - Keyestudio Smart Little Turtle Robot V3 Manual

Table of Contents

Advertisement

www.keyestudio.com
(7) Test Result:
Upload code successfully and power on, servo swings in the range of 0° to
180°. The result is same. We usually control it by library file.
(8) Code Explanation
Arduino comes with
The following are some common statements of the servo function:
1. attach(interface)——Set servo interface, port 9 and 10 are available
2.
write (angle)
range is from 0° to 180°
3. read()——The statement to read angle of servo, read the command
value of"write()"
4. attached()——Judge if the parameter of servo is sent to its interface
Note: The above written format is"servo variable name, specific statement
()", for instance: myservo.attach(9)

Project 5: Ultrasonic Sensor

(1) Description
#include <Servo.h>
——The statement to set rotation angle of servo, the angle
The HC-SR04 ultrasonic sensor uses sonar to
determine distance to an object like bats do. It
(servo function and statement)
92

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the Smart Little Turtle Robot V3 and is the answer not in the manual?

Questions and answers

Table of Contents