Navigation

    M5Stack Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. JimW
    3. Topics
    J
    • Continue chat with JimW
    • Start new chat with JimW
    • Flag Profile
    • Profile
    • Following
    • Followers
    • Blocks
    • Topics
    • Posts
    • Best
    • Groups

    Topics created by JimW

    • J

      [Solved]Driving a single servo
      Arduino • • JimW

      7
      0
      Votes
      7
      Posts
      8202
      Views

      S

      @jimw Please try this code. Serial speed 115200 and the firmware (1.2.3-en) for micropython It is not for Arduino. #include <M5Stack.h> int servoPin = 5; void servoSet(int Angle, int Time) { int pulseWidth; int TimeCount; TimeCount = Time / 20; for (int i = 0; i <= TimeCount; i++) { pulseWidth = map(Angle, 0, 180, 544, 2400); digitalWrite(servoPin, HIGH); delayMicroseconds(pulseWidth); digitalWrite(servoPin, LOW); delayMicroseconds(20000 - pulseWidth); } } void setup() { M5.begin(); M5.Lcd.printf("M5Stack Servo test:\n"); pinMode(servoPin, OUTPUT); } void loop() { M5.Lcd.printf("Angle 45deg\n"); Serial.println("Angle 45deg"); servoSet(45, 1000); //45deg M5.Lcd.printf("Angle 135deg\n"); Serial.println("Angle 135deg"); servoSet(135, 1000); //135deg }
    • J

      m5 burner and firmware
      General • • JimW

      15
      0
      Votes
      15
      Posts
      22955
      Views

      E

      @ozbk Moving to Applications directory helped! Thanks for sharing the tip!