Servo Kit 360: M5Stack ATOM Matrix
atom_servo_360_test
code: main.cpp
#define TIMER_WIDTH 16 // bit (0~65535) // PWM 50 Hz / 0.5~20 ms
// T = 1/50 = 20 ms
// 20 ms * 1600 / 65535 (16 bit) = 0.49 ms
// 20 ms * 8400 / 65535 (16 bit) = 2.56 ms
// need to adjust a little bit for each motor
void setup() {
M5.begin(true, false, true);
ledcSetup(CHANNEL, FREQ, TIMER_WIDTH);
ledcAttachPin(SERVO_PIN, CHANNEL);
}
void loop() {
M5.dis.drawpix(0, 0, 0x00ff00);
// ledcWrite(CHANNEL, COUNT_LOW);
// delay(1000);
for(int com = COUNT_LOW; com < COUNT_HIGH; com = com + 100){
ledcWrite(CHANNEL, com);
delay(50);
}
M5.dis.drawpix(0, 0, 0x0000ff);
// ledcWrite(CHANNEL, COUNT_HIGH);
// delay(1000);
for(int com = COUNT_HIGH; com > COUNT_LOW; com = com - 100){
ledcWrite(CHANNEL, com);
delay(50);
}
}