Controlling a Servo motor using interrupts without servo library


i have been trying control servo motor without servo library due conflict in library using.

a problem have been running servo motor jitters unless send frequency.

i figured use interrupt control servo way sent same frequency , therefore not jitter.

i have never worked timer interrupts before working on dummy code make sure understand it.
here have:
code: [select]
#include <timerone.h>

void setup()
{
  //initialize digital pin output.
  pinmode(22, output);
  timer1.initialize(10000); //set timer of length in microseconds
  timer1.attachinterrupt(timerisr); //attach service routine here

}

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

}

void timerisr()
{
  //toggle pwm
  digitalwrite(22, !digitalread(22));
}



the problem approach pin high , low equal amount of time changing frequency , not position.

is possible have high 30% or 90% of time corresponding position staying @ same frequency?

thanks in advance

have tried servotimer2 library?

the standard servo library uses timer1

...r


Arduino Forum > Using Arduino > Project Guidance > Controlling a Servo motor using interrupts without servo library


arduino

Comments

Popular posts from this blog

Help with codes to add 1 more shift register and add more to matrix LED

tcp client

Can't read sms using Thinker A7 communicate with Arduino