Conflict VirtualWire ServoTimer2

i´m writing code for a RC-Car and have a problem with controlling a servo.
I want to send data from one Arduino to another and steer a servo there. I use ServoTimer2 to not get in conflict with the timer of vw and the servo-library. But when i try to controll the Servo i can´t receive new data anymore. Controlling the Servo without vw is no problem. I tried even a few other pins but it doesn´t change anything.
Has anybody an idea where the problem could be?

Maybe in the code that you did not post?

/*Code zur Steuerung eines RC Cars mit DC-Motor mithilfe einer Fernbedienung
  Erstellt für T1000 TMB21 DHBW Mannheim
  PFW Aerospace GmbH Speyer
  programmiert von Lars Peters*/
#include <VirtualWire.h>
#include <ServoTimer2.h>

#define motorpin1 13
#define motorpin2 12
#define motorpinspeed 6

#undef int
#undef abs
#undef double
#undef float
#undef round

ServoTimer2 lenkung;

void setup()
    pinMode(motorpinspeed, OUTPUT); 
    vw_set_ptt_inverted(true);    // Required for RX Link Module
    vw_setup(2000);                   // Bits per sec
    vw_set_rx_pin(2);           // We will be receiving on pin 2 i.e the RX pin from the module connects to this pin. 
    vw_rx_start();                      // Start the receiver 

void loop()
    int values[3];
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;

    if (vw_get_message(buf, &buflen)) // check to see if anything has been received

    for (int i = 0; i < 3; i++)
      values[i] = word(buf[i*2+1], buf[i*2]);
      Serial.print(i, DEC);
      Serial.print(values[i], DEC);
      Serial.print("  ");
    int geschw = map(values[0], 510,1023,0,255);  //Umrechnen der Joystick-Werte in PWM-Wert für Geschwindigkeit
    int winkel = map(values[1], 510,1023,1500,2250); //Umrechnen in Winkel für Lenkservo
        digitalWrite(motorpin1, HIGH);
        digitalWrite(motorpin2, LOW);
        analogWrite(motorpinspeed, geschw); //Motor mit mind. 50 PWM, sonst ungleichmäßiger Lauf
    else if(geschw<-50) 
        digitalWrite(motorpin1, LOW);
        digitalWrite(motorpin2, HIGH);
        analogWrite(motorpinspeed, abs(geschw));
        analogWrite(motorpinspeed, 0);
analogWrite(motorpinspeed, geschw); //Motor mit mind. 50 PWM, sonst ungleichmäßiger Lauf

Check whether the above uses Timer1, in conflict with VirtualWire.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.