Hello,
I have a question concerning the code of Servo.h and Servo.cpp that is included in Arduino.
Basically I have examined the code - as it gives me the possibility to understand C++ better.
But I have one problem:
- I cannot find how the pin is set high in Servo.h and Servo.cpp - just like the digitalWrite function from Arduino.
I ve posted the code with the specific function:
void Servo::write(int value)
{
if(value < MIN_PULSE_WIDTH)
{ // treat values less than 544 as angles in degrees (valid values in microseconds are handled as microseconds)
if(value < 0) value = 0;
if(value > 180) value = 180;
value = map(value, 0, 180, SERVO_MIN(), SERVO_MAX());
}
this->writeMicroseconds(value);
}
void Servo::writeMicroseconds(int value)
{
// calculate and store the values for the given channel
byte channel = this->servoIndex;
if( (channel < MAX_SERVOS) ) // ensure channel is valid
{
if( value < SERVO_MIN() ) // ensure pulse width is valid
value = SERVO_MIN();
else if( value > SERVO_MAX() )
value = SERVO_MAX();
value = value - TRIM_DURATION;
value = usToTicks(value); // convert to ticks after compensating for interrupt overhead - 12 Aug 2009
uint8_t oldSREG = SREG;
cli();
servos[channel].ticks = value;
SREG = oldSREG;
}
But I cannot find anywhere a command to set pin high (for the duration int value that is called with the function ).
Would appreciate help very much :).