[フレーム]
Keil Studio Cloud

Important update: Arm Announces End of Life Timeline for Mbed. This site will be archived in July 2026. Read the full announcement.

Servo/kr

« Servo

Table of Contents

  1. 헬로 월드!
  2. Library
  3. Details

A library for controlling a Radio Control (R/C) model Servo.

R/C Model Servo

헬로 월드!

Import program

00001 // Hello World to sweep a servo through its full range
00002 
00003 #include "mbed.h"
00004 #include "Servo.h"
00005 
00006 Servo myservo(p21);
00007 
00008 int main() { 
00009  for(float p=0; p<1.0; p += 0.1) {
00010  myservo = p;
00011  wait(0.2);
00012  }
00013 }

Library

Import library

Public Member Functions

Servo (PinName pin)
Create a servo object connected to the specified PwmOut pin.
void write (float percent)
Set the servo position, normalised to it's full range.
float read ()
Read the servo motors current position.
void position (float degrees)
Set the servo position.
void calibrate (float range=0.0005, float degrees=45.0)
Allows calibration of the range and angles for a particular servo.
Servo & operator= (float percent)
Shorthand for the write and read functions.

This library controls a standard R/C model servo using a PwmOut signal, and provides control of the servo between min and max by setting it to 0.0 - 1.0.

As all servos respond differently, you can also use the calibrate function the range, so 0.0 - 1.0 is the maximum range of the servo.

Details


All wikipages
Recent changes
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.

Access Warning

You do not have the correct permissions to perform this operation.

×

AltStyle によって変換されたページ (->オリジナル) /