mirror of
https://github.com/esp8266/Arduino.git
synced 2025-07-30 16:24:09 +03:00
Merge remote-tracking branch 'arduino/master' into ide-1.5.x
Conflicts: libraries/Ethernet/examples/XivelyClient/XivelyClient.ino libraries/Ethernet/examples/XivelyClientString/XivelyClientString.ino libraries/GSM/examples/GSMXivelyClient/GSMXivelyClient.ino libraries/GSM/examples/GSMXivelyClientString/GSMXivelyClientString.ino libraries/Servo/examples/Knob/Knob.ino libraries/Servo/examples/Sweep/Sweep.ino libraries/WiFi/examples/WiFiXivelyClient/WiFiXivelyClient.ino libraries/WiFi/examples/WiFiXivelyClientString/WiFiXivelyClientString.ino
This commit is contained in:
@ -1,31 +1,35 @@
|
||||
// Sweep
|
||||
// by BARRAGAN <http://barraganstudio.com>
|
||||
// This example code is in the public domain.
|
||||
/* Sweep
|
||||
by BARRAGAN <http://barraganstudio.com>
|
||||
This example code is in the public domain.
|
||||
|
||||
modified 8 Nov 2013
|
||||
by Scott Fitzgerald
|
||||
http://arduino.cc/en/Tutorial/Sweep
|
||||
*/
|
||||
|
||||
#include <Servo.h>
|
||||
#include <Servo.h>
|
||||
|
||||
Servo myservo; // create servo object to control a servo
|
||||
// twelve servo objects can be created on most boards
|
||||
|
||||
int pos = 0; // variable to store the servo position
|
||||
|
||||
void setup()
|
||||
{
|
||||
myservo.attach(9); // attaches the servo on pin 9 to the servo object
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
for(pos = 0; pos <= 180; pos += 1) // goes from 0 degrees to 180 degrees
|
||||
{ // in steps of 1 degree
|
||||
myservo.write(pos); // tell servo to go to position in variable 'pos'
|
||||
delay(15); // waits 15ms for the servo to reach the position
|
||||
}
|
||||
for(pos = 180; pos>=0; pos-=1) // goes from 180 degrees to 0 degrees
|
||||
{
|
||||
myservo.write(pos); // tell servo to go to position in variable 'pos'
|
||||
delay(15); // waits 15ms for the servo to reach the position
|
||||
}
|
||||
}
|
||||
|
||||
Servo myservo; // create servo object to control a servo
|
||||
// a maximum of eight servo objects can be created
|
||||
|
||||
int pos = 0; // variable to store the servo position
|
||||
|
||||
void setup()
|
||||
{
|
||||
myservo.attach(9); // attaches the servo on pin 9 to the servo object
|
||||
}
|
||||
|
||||
|
||||
void loop()
|
||||
{
|
||||
for (pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees
|
||||
{ // in steps of 1 degree
|
||||
myservo.write(pos); // tell servo to go to position in variable 'pos'
|
||||
delay(15); // waits 15ms for the servo to reach the position
|
||||
}
|
||||
for (pos = 180; pos >= 1; pos -= 1) // goes from 180 degrees to 0 degrees
|
||||
{
|
||||
myservo.write(pos); // tell servo to go to position in variable 'pos'
|
||||
delay(15); // waits 15ms for the servo to reach the position
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user