Quantcast
Channel: Servo controllers and servos - Pololu Forum
Viewing all articles
Browse latest Browse all 83

ServoTimer2 Library Compilation Error

$
0
0

Hi, I am wondering if someone can help. I have a problem using arduino Servo library. I have arduino Uno R3 board. To inject PWM to ESC to run a brushless motor.

When I use FreqCount library + Servo Library , it does not work. I been searching every corner of the internet to find a solution. The problem is that, the timer1 is used on both library that causing the issue.

I have found few posts on the internet suggesting to use ServoTimer2 library. Which I have installed and was trying to use it like Servo library. If I use the same code for Servo.h , it works fine, but does not work for ServoTimer2.h.

But there is a compilation error.

here is my code

#include <ServoTimer2.h>

#define esc_pin 6
#define pot_input_pin A0

int pot_value;
int pwm_frequency;
int min_pulse_width = 1000;
int max_pulse_width = 2000;

ServoTimer2 PWM;

void setup() {
  // put your setup code here, to run once:

  pinMode(esc_pin, OUTPUT);
  pinMode(pot_input_pin, INPUT);

  PWM.attach(esc_pin, min_pulse_width, max_pulse_width);

  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:

      pot_value = analogRead(pot_input_pin);
      pwm_frequency = map(pot_value, 0, 1023, 0, 180);
      PWM.write(pwm_frequency);

      Serial.print(pwm_frequency);
      delay(500);
}

errors

-------------------------------------------------

C:\Users\OLI~1.AHM\AppData\Local\Temp\cc5XJxoo.ltrans0.ltrans.o: In function `setup':
C:\Users\Misc\Arduino Giga R1\Sketch\ServoTimer2_Sketch/ServoTimer2_Sketch.ino:19: undefined reference to `ServoTimer2::attach(int, int, int)'
collect2.exe: error: ld returned 1 exit status

exit status 1

Compilation error: exit status 1

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 83

Trending Articles