Using 360° servo with M5Stack Servo-module

How do I set the speed and direction of a 360° servo with M5Stack Servo-module? The Servo script shows how to set the angle of a normal (180°) servo, but using this script a 360° servo just spins in a clockwise direction at a constant speed whatever the settings are.

over 90 degrees for one direction, less for the other, difference from 90 digrees is the speed.

Thanks! I have written a function,

Servo_write_360()

which I can call with say 100 or 80

void Servo_write_360(uint8_t angle) {
    Wire.beginTransmission(SERVO_ADDR);
    Wire.write(angle);
    Wire.endTransmission();
}

However, whatever value I call the function with, the servo keeps going in the same direction at the same speed.

Does the servo have a forward and reverse mode?

Post a link to both the controller & servo you have.

As reported in the OP the controller is a M5Stack Servo-module https://eckstein-shop.de/M5Stack-SERVO-Module-Board-12-Channels?curr=EUR&gclid=CjwKCAiAuoqABhAsEiwAdSkVVCPisR_XiwHrekfAD84nS_EM4sdlf0wlzLdUq0TCkMR-ZeWw0fJK8BoCm1wQAvD_BwE

The servo is an "ezrobot 360" from an ezrobot kit. It must have forward and reverse modes because both are utilised when using the ezrobot controller.

For completemess, here is the example sketch that works with the M5Stack Servo-module and a 180° servo:

/*
    Description: Use SERVO Module to control the rotation of 12-channel servo.
*/
#include <Arduino.h>
#include <M5Stack.h>
#include <Wire.h>


#define SERVO_ADDR 0x53
void setup() {
    M5.begin(true, false, true);
    M5.Power.begin();
    M5.Lcd.setTextFont(4);
    M5.Lcd.setCursor(70, 100);
    M5.Lcd.print("Servo Example");


    Wire.begin(21, 22, 100000);
    //Servo_write_360(92);
    // put your setup code here, to run once:
}


// addr 0x01 mean control the number 1 servo by us
void Servo_write_us(uint8_t number, uint16_t us) {
    Wire.beginTransmission(SERVO_ADDR);
    Wire.write(0x00 | number);
    Wire.write(us & 0x00ff);
    Wire.write(us >> 8 & 0x00ff);
    Wire.endTransmission();
}


// addr 0x11 mean control the number 1 servo by angle
void Servo_write_angle(uint8_t number, uint8_t angle) {
    Wire.beginTransmission(SERVO_ADDR);
    Wire.write(0x10 | number);
    Wire.write(angle);
    Wire.endTransmission();
}


void loop() {
    
    for(uint8_t i = 0; i < 12; i++){
        //Servo_write_us(i, 700);
        Servo_write_angle(i, 0);
    }
    delay(1000);
    for(uint8_t i = 0; i < 12; i++){
        //Servo_write_us(i, 2300);
        Servo_write_angle(i, 90);
    }
         delay(1000);
}

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.