Servo::readMicroseconds()\ Servo \ Language (API) \ Wiring ALPHA 1.0
Author: Hernando Barragán
Description: Wiring is an electronic sketchbook and hardware electronics for developing ideas. It is a context for learning fundamentals of computer programming and prototyping with electronics within the context of the electronic arts.
Keywords: Wiring, Processing, Interactive Media, Electronic Arts, Programming, C, C++, Hernando Barragán

Search wiring.org.co:

Reference for Wiring version 0023+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Class | Servo
Name | ### readMicroseconds()
Examples |
    #include "Servo.h"

    int myled = 0;
    Servo myservo;

    void setup() {
      pinMode(myled, OUTPUT);
      digitalWrite(myled, LOW);  // set off the LED
      myservo.attach(2)          // attaches a servo connected to pin 2
                                 // to the servo channel 0
    }

    void loop() {
      myservo.writeMicroseconds(1494);  // sets the servo position at 90 degrees
      if(myservo.readMicroseconds() >= 1494)   // if servo position is greater than 90 degrees
      {
        digitalWrite(myled, HIGH);  // turn on the LED
      }
    }
Description | The readMicroseconds() method returns the last written servo pulse width in microseconds.
Syntax |
    servo.readMicroseconds()
Parameters |
servo | Any variable of type Servo
Returns | int
Usage | Application

Updated on November 01, 2009 08:45:42am PST