Tutorial.Sweep History

Hide minor edits - Show changes to output

November 13, 2012, at 10:43 AM by Roberto Guido - corrected link for map(). Thanks Matt Rodriguez for the alert
Changed lines 46-47 from:
* [[Reference/For| @@map()@@]]
to:
* [[Reference/Map| @@map()@@]]
November 16, 2011, at 04:39 AM by Scott Fitzgerald -
Changed lines 40-41 from:
(:source http://arduino.cc/en/pub/code/master/libraries/Servo/examples/Sweep/Sweep.pde lang=arduino tabwidth=4:)
to:
(:source http://arduino.cc/en/pub/code/master/libraries/Servo/examples/Sweep/Sweep.ino lang=arduino tabwidth=4:)
September 24, 2010, at 05:49 AM by Tom Igoe -
Changed lines 40-70 from:
(:source lang=arduino tabwidth=4:)

// Sweep
// by BARRAGAN <http://barraganstudio.com>

#include <Servo.h>

Servo myservo; // create servo object to control a servo

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
}
}
(:sourceend:)
to:
(:source http://arduino.cc/en/pub/code/master/libraries/Servo/examples/Sweep/Sweep.pde lang=arduino tabwidth=4:)
September 23, 2010, at 10:53 PM by Christian Cerrito -
Changed lines 3-4 from:
!!Sweep
to:
!!!Sweep
September 20, 2010, at 04:01 PM by Christian Cerrito -
Changed lines 5-6 from:
Sweeps the shaft of a servo motor back and forth.
to:
Sweeps the shaft of a RC [[http://en.wikipedia.org/wiki/Servo_motor#RC_servos | servo motor]] back and forth across 180 degrees.

This example makes use of the Arduino [[Reference/Servo | '''servo library''']].
September 20, 2010, at 03:55 PM by Christian Cerrito -
Added lines 77-78:

September 20, 2010, at 03:55 PM by Christian Cerrito -
Changed lines 71-76 from:
* [[Reference/Servo | Servo library reference]]
to:
* [[Reference/ServoAttach | @@attach()@@]]
* [[Reference/ServoWrite | @@write()@@]]
* [[Reference/For| @@map()@@]]

* [[Reference/Servo | Servo library reference]]
* [[Tutorial/Knob]] - control the position of a servo with a potentiometer.
September 20, 2010, at 03:52 PM by Christian Cerrito -
Changed lines 36-37 from:
!!!!Code
to:
!!!Code
September 20, 2010, at 03:50 PM by Christian Cerrito -
Deleted lines 4-5:
!!!!Description
Changed lines 7-8 from:
!!!!Circuit
to:
(:div class=BOM :)
!!!Hardware Required
* Arduino Board
* (1) Servo Motor
* hook-up wire

(:divend:)

(:div class=circuit :)
!!!Circuit
Added lines 20-35:

[-click the images to enlarge-]

%height=250px%[[Attach:sweep_BB.png | Attach:sweep_bb.png]]

[-images developed using [[http://www.fritzing.org |Fritzing]]. For more circuit examples, see the [[http://fritzing.org/projects/|Fritzing project page]] -]


!!!Schematic

%height=250px%[[Attach:sweep_schem.png | Attach:sweep_schem.png]]


(:divend:)

Changed lines 38-39 from:
[@
to:
(:source lang=arduino tabwidth=4:)
Changed lines 67-68 from:
@]
to:
(:sourceend:)
October 17, 2008, at 05:29 PM by Paul Badger -
Changed lines 11-12 from:
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow or orange and should be connected to pin 9 on the Arduino board.
to:
Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow, orange or white and should be connected to pin 9 on the Arduino board.
October 12, 2008, at 12:02 AM by David A. Mellis -
Changed lines 22-23 from:
// a maximum of eight servo objects can be created
to:

int pos = 0; // variable to store the servo position
Deleted lines 24-25:
int pos = 0; // variable to store the servo position
Deleted line 29:
October 11, 2008, at 11:59 PM by David A. Mellis -
Added lines 1-49:
''Examples > Servo Library''

!!Sweep

!!!!Description

Sweeps the shaft of a servo motor back and forth.

!!!!Circuit

Servo motors have three wires: power, ground, and signal. The power wire is typically red, and should be connected to the 5V pin on the Arduino board. The ground wire is typically black or brown and should be connected to a ground pin on the Arduino board. The signal pin is typically yellow or orange and should be connected to pin 9 on the Arduino board.

!!!!Code

[@
// Sweep
// by BARRAGAN <http://barraganstudio.com>

#include <Servo.h>

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
}
}
@]

!!!!See also

* [[Reference/Servo | Servo library reference]]

Share