Hi, I want to transmit and receive a character trough a 433MHz RF and then make a servo go 1600 microseconds if the character is received. I came up with these two codes which i crafted from past codes that worked fine, but now i keep getting Error compiling. If u can please take a look at it I would be grateful. Thanks.
1st Code:
#include <VirtualWire.h>
#include <Servo.h>
Servo motor;
void setup()
{
motor.attach(3);
vw_set_ptt_inverted(true); // Required for DR3100
vw_set_rx_pin(2);
vw_setup(4000); // Bits per sec
vw_rx_start(); // Start the receiver PLL running
Serial.begin(9600);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
if(buf[0]=='1') go();
}
}
void go()
{
Serial.println("1600");
motor.writeMicroseconds(1600);
}
and 2nd code:
#include <VirtualWire.h>
#include <Servo.h>
Servo motor;
void setup()
{
motor.attach(3);
vw_set_ptt_inverted(true); // Required for DR3100
vw_set_rx_pin(2);
vw_setup(4000); // Bits per second
vw_rx_start(); // Start the receiver PLL running
Serial.begin(9600);
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
if(buf[0]=='F')
{
Serial.println("1600");
motor.writeMicroseconds(1600);
}
}
}