Does anyone have a working example for the SERVO Module Board 12 Channels? I'm using the code below with single servo on port 1 and all I get when I run this code is "Servo Example" written across the M5Core screen but no movement whatsoever from the servo. Note the ports on the module are 0 thru 11 and my servo is plugged into 1 because the pins on port zero are too close to the module case to get my servo plug in anywhere on that row.
Also, for the to Servo_write_angle(uint8_t number, uint16_t us) and Servo_write_us(uint8_t number, uint16_t us) is number the port number (0..11)?
Thanks in advance.
#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, 100000UL);
}
// 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);
}