Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 8 of 8

Thread: New at Platformio and teensy 4.0. Servo.h error

  1. #1
    Junior Member
    Join Date
    Feb 2021
    Posts
    1

    New at Platformio and teensy 4.0. Servo.h error

    I'm trying to control a drone motor with teensy 4.0. This is my code:

    #include <Servo.h>
    #define pin_esc 23
    Servo esc;


    void setup() {
    esc.attach(pin_esc);
    esc.writeMicroseconds(1000);
    delay(1000);

    }

    void loop() {
    int val = analogRead(A0);
    //val = map(val, 0, 1023, 1000, 2000);
    esc.writeMicroseconds(1500);
    delay(15);
    }

    In teensyduino 1.8.13 works well, but when I trying in Platformio i get this error:
    "This library only supports boards with an AVR, SAM or SAMD processor."

    I looked for the servo lib in teensyduino but I didn't find it.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    23,951
    I'm not sure what to do with PlatformIO, but here's a link to the Servo library Teensyduino uses.

    https://github.com/PaulStoffregen/Servo

    Maybe you can somehow import this to PlatformIO?

  3. #3
    Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    47
    On my machine with PlatformIO, the teensy specific Servo library is located at ~/.platformio/packages/framework-arduinoteensy/libraries/Servo/Servo.h

  4. #4
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,712
    Quote Originally Posted by thebigg View Post
    On my machine with PlatformIO, the teensy specific Servo library is located at ~/.platformio/packages/framework-arduinoteensy/libraries/Servo/Servo.h
    It sounds like PlatformIO is using an old version of the Servo library. I don't use PlatformIO so you may what to report it to them.

    You might try downloading the latest and greatest Servo library from PJRC and replacing the Servo files at that location. Don't know if it would break anything else though.

  5. #5
    Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    47
    Quote Originally Posted by mjs513 View Post
    It sounds like PlatformIO is using an old version of the Servo library. I don't use PlatformIO so you may what to report it to them.

    You might try downloading the latest and greatest Servo library from PJRC and replacing the Servo files at that location. Don't know if it would break anything else though.
    The files at that location are identical to the files at the link that Paul posted.

    The only place that contains the string
    Code:
    "This library only supports boards with an AVR, SAM or SAMD processor."
    is the arduino specific header. On my machine this is installed at /usr/share/arduino/libraries/Servo/src/Servo.h.

    Somehow PlatformIO is picking up the wrong version during build...

  6. #6
    Senior Member+ mjs513's Avatar
    Join Date
    Jul 2014
    Location
    New York
    Posts
    6,712
    Quote Originally Posted by thebigg View Post
    The files at that location are identical to the files at the link that Paul posted.
    Well using the Arduino IDE I just compiled your sketch with no errors or warnings.

    Click image for larger version. 

Name:	Capture.PNG 
Views:	7 
Size:	153.2 KB 
ID:	23757

    I am assuming you have to select Teensy 4 in platformIO so only other thing is are you sure you are compiling for Teensy 4. Other than that, sounds like its a platformIO issue which I can't help you with - dont know anything about platformIO.

  7. #7
    Member
    Join Date
    Aug 2018
    Location
    Brisbane, Australia
    Posts
    47
    Quote Originally Posted by mjs513 View Post
    I am assuming you have to select Teensy 4 in platformIO so only other thing is are you sure you are compiling for Teensy 4. Other than that, sounds like its a platformIO issue which I can't help you with - dont know anything about platformIO.
    Either the OP has not installed the teensy framework, or the board = directive in platformio.ini is missing or wrong

  8. #8
    Junior Member
    Join Date
    Mar 2021
    Posts
    1
    I had the same problem as OP, but it was solved with replacing the servo library in platformio with the library from PaulStoffregen.
    My library was located at C:\Users\usr\.platformio\lib\Servo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •