/M5StackSimpleServo

A library for controlling servo motor in M5Stack

Primary LanguageC++MIT LicenseMIT

M5StackSimpleServo

A library for controlling servo motor in M5Stack.

This library has been tested on the M5Stack Gray.

Quick Start

Download Library

Download this library from the repository as ZIP, and place in ~/Documents/Arduino/libraries/.

Connect Servo Motor to M5Stack

Connect 5V and GND, and connect the signal wire to GPIO 5.

Write Sample Sketch

Include this library, and open sample sketch.

Write the sketch to M5Stack, then the servo motor should work!

Class Reference

Member Functions

M5StackSimpleServo::M5StackSimpleServo

Description

A constructor that initializes the ledc configuration.

args
  • ledc_channel: Number of Channel to use.
  • pwm_min_width: Minimum duty ratio of the control pluse of servo motor. default is 500[us]
  • pwm_max_width: Maximum duty ratio of the control pluse of servo motor. default is 2400[us]
  • ledc_freq: PWM freqency. default is 50.0
  • ledc_timer_bit: Number of full scale bits for duty indication. default is 16

M5StackSimpleServo::attach(uint8_t output_pin)

Description

A function to assign a pin to the PWM channel.

arg
  • output_pin: Number of GPIO to use.

M5StackSimpleServo::write(int value)

Description

A function to write signals to the servo motor.

arg
  • value: the value to write to the servo motor, from 0 to 180

M5StackSimpleServo::writeMicroseconds(int value)

Description

A function to write signals to the servo motor in microseconds.

arg
  • value: the value to write to the servo motor in microseconds.

M5StackSimpleServo::detach

A function to detach the pin from the PWM channel.