myservo.detach() doesn't work

Hey guys!

Somehow if I use the servo.detach() method, I still can't use the Pins 9 and 10 for PWM altough that is what it sais in the description of the Servo library

e.g.

Servo servo;

...

servo.attach(6);
servo.write(90);
delay(1000);
servo.detach();

analogWrite(9, 200);

Does somebody know why it doesn't work properly?7

Cheers

Torrentula

Does somebody know why it doesn't work properly?7

Based on the code snippet, no. You need to post all of your code.

I'm having a similar problem. I am using a Teensy 2.0 as a small platform for a tiny tracked robot I am building to do mapping with. I want to use a servo to sweep some sensors back and forth.

I have it attached to pin 4

Here is a small snippet of code.

#include <Servo.h>
Servo myservo;

int righttrack  = 14;
int lefttrack = 15;
// SMD LED onboard Teensy 2.0
int led = 11;

void setup() {
pinMode(righttrack, OUTPUT);
pinMode(lefttrack, OUTPUT);
pinMode(led, OUTPUT);

//center servo (attach pin 4)
myservo.attach(4);
myservo.write(90);

//detach servo so I can use PWM
myservo.detach();
}

void loop() {

// Testing (Drive robot foward 1 second)
  analogWrite (righttrack, 250);
  analogWrite (lefttrack, 250); 
  delay(1000);

// Stop Motors to attach servo
  analogWrite (righttrack, 0);
  analogWrite (lefttrack, 0);

//attach servo and sweep
myservo.attach(4);
myservo.write(180);
delay(1000);
myservo.write(0);
delay(1000);
myservo.write(90);
delay(1000);

// Detach servo to use PWM 
  myservo.detach();
  delay(1000);
  
}

If I use Servo.h pins 9 and 10 are unavailable even if I use myservo.detach();
If I use PWMServo.h the opposite is true as pins 14 and 15 are unavailable even if I use myservo.detach();

Does anyone know why myservo.detach(); does not work?

Even though pins 9 and 10 are not used in the test code above I do plan on using them to drive other peripherals on my robot. The above code appears to function properly but if pins 9 and 10 are used with analogWrite(pin, value); they do not function

Did anyone read the Servo library reference over at the Reference section on the Main Site?
Just a thought :wink:

Description

Detach the Servo variable from its pin. If all Servo variables are detached, then pins 9 and 10 can be used for PWM output with analogWrite().

With all servos detached, analogWrite(); does not work.

I am using a Teensy 2.0

Check the name on the door on your way into this forum. See Teensy anywhere in the name?

PaulS guess my specific arduino platform is just not good enough for you.

Personal insult removed. Moderator.

I bid you good day sir,

w00tb0t:
PaulS guess my specific arduino platform is just not good enough for you. Removed here too.
Moderator.

I bid you good day sir,

Considering that your contribution to the forum consists of three posts begging for help, and PaulS's contribution consists of many thousands of posts providing help, I don't think you're in any position to insult him. If your question is not about Arduino, perhaps you'll find people willing and able to help if you ask on a forum specific to your platform. Although, with your attitude, perhaps you won't.

(deleted)