Public Documentation
  • Introduction
  • Getting started
    • Introduction
    • 1. Welcome Page
    • 2. Introduction (Beginner's Guide)
  • Portal Tools
    • Blocko
      • Ůvod do blocka
      • Flip-flop
      • REST-API bloček
    • Grid
      • Úvod do GRID
      • Základní Tlačítko (základy GRID)
      • vylepšený Přepínač (stylování a pokročilé možnosti GRID)
      • text generátor button (messeage type, two elements one widget)
      • graf (pokročilé funkce GRID)
      • Slider (User class v GRIDu)
      • Styly a jejich použití
  • Cloud
    • Cloud
    • Instancies
    • Rest-Api
  • General
    • What we plan
  • Hardware a programování
    • Úvod
      • Nahrání prvního programu
    • Konektivita
      • Specifikace zdroje internetu
      • GSM
      • 6LowPAN
      • Komunikace s portálem
      • Přepínání mezi servery
    • Hardware
      • Základní jednotky
        • IODAG3E
          • Rozhraní a periférie
          • Konektor X a Y
          • Napájení
          • Připojení zdroje k VBAT
          • Paměti
          • Technické specifikace
          • Schémata
        • IODAG3L
      • Rozšiřující moduly
        • GSM shield
        • LED shield
        • Relay shield
        • RFID shield
        • Ultrasonic shield
        • Meteo shield
        • Movement shield
        • PIR shield
        • RGB Displej shield
        • Serial shield
      • Ostatní
        • DevKitG3
          • Schéma
        • TK3G
          • Schéma
        • ZPPG3
          • Schéma
        • WEXP
    • Programování HW
      • Architektura FW
        • Aktualizace FW
        • Autobackup
      • Struktura programu
      • Byzance API
        • Vstupy a výstupy do Portálu
        • Callback Busy
        • Odložený restart
        • Callbacky připojení
        • Uživatelská makra
      • MBED API
        • Vstupy a výstupy
        • Komunikační rozhraní
        • Časování
        • RTOS
      • Knihovny
        • DHT
        • DS1820
        • Dali
        • EdgeStruct
        • I2CWrapper
        • Knock
        • MFRC522
        • MFRC522::MIFARE_Key
        • MPU9150
        • ms5637
        • OneWire
        • PCA9536
        • RGB_matrix
        • RollerDrive
        • SHT21
        • ST7565
        • Servo
        • TCA6424A
        • TLC59116
        • TripleSevenSeg
        • MFRC522::Uid
        • WS2812
        • WakeUp
      • Offline programování
        • Vlastní IDE
        • Upload kódu z GUI
        • Upload kódu z konzole
        • Upload kódu Drag&drop
    • Tutoriály
      • Datum a čas (RTC)
      • Komunikace po sériové lince (UART) s PC
        • Konfigurace sériové linky v PC
        • Programování sériové linky
      • Základní tutoriály
        • Digital Read
        • Analog Read/Write
        • PWM Fade
        • Timer/Ticker
        • State Change Detection
        • Ovládání LED modulu
        • BusOut
        • HC-SR04 Senzor
      • Pokročilé
    • Správa a diagnostika
      • Zdroj restartu
      • LED modul
      • Identifikace zařízení
      • Monitoring parametrů
      • Vytížení zařízení
      • Webové rozhraní
        • Základní přehled
        • Správce firmware
        • Vlákna
        • Definované vstupy
        • Konfigurace MQTT
        • Nastavení
      • Bootloader
        • Režimy bootloaderu
        • Command mód
        • Další vlastnosti bootloaderu
      • Webová konzole
      • Konfigurace zařízení
        • Confighash
      • Omezení konfigurace
        • Konfigurace
        • Binárky
        • Omezení MQTT
        • Lowpan
    • Knowledge base
      • Náhodná čísla
      • Watchdog
      • Paměť RAM
Powered by GitBook
On this page
  • Protected Attributes
  • Public Functions
  • Detailed Description
  • Protected Attributes Documentation
  • variable _pwm
  • variable _range
  • variable _degrees
  • variable _p
  • Public Functions Documentation
  • function Servo
  • function write
  • function read
  • function position
  • function calibrate
  • function operator=
  • function operator=
  • function operator float
  1. Hardware a programování
  2. Programování HW
  3. Knihovny

Servo

PreviousST7565NextTCA6424A

Last updated 6 years ago

Driver for PWM controlled servo motors.

Protected Attributes

Type

Name

PwmOut

float

float

float

Public Functions

Type

Name

void

float

void

void

Detailed Description

// Continuously sweep the servo through it's full range
#include "mbed.h"
#include "Servo.h"

Servo myservo(p21);

int main() {
    while(1) {
        for(int i=0; i<100; i++) {
            myservo = i/100.0;
            wait(0.01);
        }
        for(int i=100; i>0; i--) {
            myservo = i/100.0;
            wait(0.01);
        }
    }
}

Protected Attributes Documentation

PwmOut Servo::_pwm;
float Servo::_range;
float Servo::_degrees;
float Servo::_p;

Public Functions Documentation

Servo::Servo (
    PinName pin
)

Create a servo object connected to the specified PwmOut pin

Parameters:

  • pin PwmOut pin to connect to

void Servo::write (
    float percent
)

Set the servo position, normalised to it's full range

Parameters:

  • percent A normalised number 0.0-1.0 to represent the full range.

float Servo::read ()

Read the servo motors current position

Parameters:

  • returns A normalised number 0.0-1.0 representing the full range.

void Servo::position (
    float degrees
)

Set the servo position

Parameters:

void Servo::calibrate (
    float range = 0.0005,
    float degrees = 45.0
)

Allows calibration of the range and angles for a particular servo

Parameters:

  • range Pulsewidth range from center (1.5ms) to maximum/minimum position in seconds

  • degrees Angle from centre to maximum/minimum position in degrees

Servo & Servo::operator= (
    float percent
)

Shorthand for the write and read functions

Servo & Servo::operator= (
    Servo & rhs
)
Servo::operator float ()

The documentation for this class was generated from the following file: D:/w/hw-libs/\_libs\_/libraries/Servo.h

(PinName pin)

(float percent)

()

(float degrees)

(float range = 0.0005, float degrees = 45.0)

&

(float percent)

&

( & rhs)

()

control class, based on a PwmOut Example:

variable

variable

variable

variable

function

function

function

function

degrees position in degrees

function

function

function

function

Servo
Servo
More...
_pwm
_range
_degrees
_p
Servo
write
read
position
calibrate
operator=
operator=
operator float
Servo
Servo
_pwm
_range
_degrees
_p
Servo
write
read
position
calibrate
operator=
Servo
operator=
operator float