using the M5 with firmware 1.2.3en and arduino 1.8.9
I know you can't use servo.h, so I came up with a work around, or at least I thought I did.
I cannot have M5.begin(); in the code or the servo doesn't work, without that the servo works but I cannot write to display.
Is there a solution? here's the example code;
#include <M5Stack.h>
#define servoPin 5
int i = 0;
int servoPulse(int angle) {
int pulseWidth = map(angle, 0, 180, 544, 2400);
return pulseWidth;
}
void setup() {
m5.begin();
Serial.begin(9600);
pinMode(servoPin, OUTPUT);
}
void loop() {
for (int i=0; i<=180; i++) { // drive servo from 0 to 180 at max response
int pulseWidth = servoPulse(i);
//digitalWrite(servoPin, HIGH);
delayMicroseconds(pulseWidth);
//digitalWrite(servoPin, LOW);
delayMicroseconds(20000 - pulseWidth);
Serial.print(i);
}
for (int i=180; i>=0; i--) { // return to 0 at half speed
int pulseWidth = servoPulse(i);
//digitalWrite(servoPin, HIGH);
delayMicroseconds(pulseWidth);
//digitalWrite(servoPin, LOW);
// delayMicroseconds(20000 - pulseWidth);
delay(50);
Serial.print(i);
}
}