Wireless 2 position servo

Hello all,
I’m trying to make a contraption where you press a button on one board and it moves the servo either to 90 degrees or 180 degrees. If it’s at 90 then it moves to 180 and vice versa. I’m not very knowledgeable when it comes to this stuff as this is my first major project so bear with me. I already have the wireless system working (thanks to hours of Googling) and a toggle system for an LED (for testing to see if the wireless is working). I’m using one of the tiny RF transmitters, two Nano’s, and a servo from radio shack. Here is the code for the receiver end of things:

#include <VirtualWire.h>
#include <ServoTimer2.h>
const int releu_pin = 9;
const int servoPin = 6;
const int transmit_pin = 12;
const int receive_pin = 3;//pin connected between RX module and Arduino
const int transmit_en_pin = 5;

ServoTimer2 myservo;  

void setup()
{
    myservo.attach(servoPin);
    myservo.write(90);
    //delay(1000);
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true);
    vw_setup(2000);//speed communication bps

    vw_rx_start();       // activate receiving mode

    pinMode(releu_pin, OUTPUT);
    
    
}

void loop()
{
    uint8_t buf[VW_MAX_MESSAGE_LEN];
    uint8_t buflen = VW_MAX_MESSAGE_LEN;
    if (vw_get_message(buf, &buflen))  //verify if any data is received
    { 
      if(buf[0]=='1')//if received 1 turn ON releu_pin 
      {
        myservo.write(180);
        digitalWrite(releu_pin , HIGH);
        //delay(15); 
      }  
     if(buf[0]=='0')
     {
        myservo.write(90);
        digitalWrite(releu_pin , LOW);
        //delay(15); 
    }
  }
}

Do you have a question?

AWOL:
Do you have a question?

Whoops, sorry. Wrote his post late at night after working on the project for hours.

The servo isn't working and I can't figure out why.

Have you tried a simple sweep test of the servo?

AWOL:
Have you tried a simple sweep test of the servo?

I've successfully ran the sweep test file in the example files if that's what you're asking. I've also modified said code to operate off a push button.

Is the realeu triggering as expected?
If you replace the servo commands with code to blink the onboard led does the led respond?

Are you sending the numbers 1 and 0 or chars '1' and '0'?

cattledog:
Is the realeu triggering as expected?
If you replace the servo commands with code to blink the onboard led does the led respond?

Are you sending the numbers 1 and 0 or chars ‘1’ and ‘0’?

Yes realeu works as expected. I’m sending the char 1 and 0. Here is the transmitter code:

#include <VirtualWire.h>
const int transmit_pin = 2;//transmit pin connected between TX module and Arduino
const int receive_pin = 2;
const int transmit_en_pin = 3;
const int buton_sw = 9;
int var_apasare = 0;

void setup()
{
    delay(1000);
    vw_set_tx_pin(transmit_pin);
    vw_set_rx_pin(receive_pin);
    vw_set_ptt_pin(transmit_en_pin);
    vw_set_ptt_inverted(true);
    vw_setup(2000);       // speed of communication bps
    pinMode(buton_sw, INPUT);
}

int contor = 1;

void loop()
{
  var_apasare = digitalRead(buton_sw);
  if (var_apasare == HIGH)
  {
    if (contor == 1) {  
      char msg[1] = {'1'};
      vw_send((uint8_t *)msg, 1);
      vw_wait_tx(); 
      contor = 0;
      delay (500);
  }
  else
  {
    if (contor == 0) {   
      char msg[1] = {'0'};
      vw_send((uint8_t *)msg, 1);
      vw_wait_tx(); 
      contor = 1;
      delay (500);
  }
  }
  }
}

Got it figured out. ServoTimer2 is in milliseconds, not degrees like the servo library that comes with the board.

zenixnet:
Got it figured out. ServoTimer2 is in milliseconds, not degrees like the servo library that comes with the board.

That would be "microseconds"