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
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
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.