keyestudio
between #include and <Servo.h>. Otherwise, it will cause compile error.
Servo myservo;// define servo variable name
void setup()
{
myservo.attach(9);// select servo pin(9 or 10)
}
void loop()
{
myservo.write(90);// set rotate angle of the motor
}
//////////////////////////////////////////////////////////
Above are the two methods to control the servo. You can choose either one according to your
liking or actual need.
*******************************************************************************
Project 29: Rotary Encoder
Introduction
The rotary encoder can count the pulse outputting times during the process of its rotation in
positive and reverse direction by rotating. This rotating counting is unlimited, not like potential
counting. It can be restored to initial state to count from 0 with the button on rotary encoder.
Hardware required
1 * Uno board
1 * Breadboard
1 * USB cable
1 * Rotar Encoder
2 * Red M5 LED
2 * 220Ω resistor
2 * 10KΩ resistor
Jumper wires
Schematic diagram
www.keyestudio.cc
136
Need help?
Do you have a question about the ARDUINO maker learning kit and is the answer not in the manual?