Stap 13: Arduino ontvanger Software
#include < VirtualWire.h >
int sicaklik;
int de nem;
int i;
char x;
char StringReceived [6];
void setup {Serial.begin(115200);
vw_set_rx_pin(11); vw_setup(2400);
vw_rx_start();
}
void loop
{
if(Serial.available() > 0)
x=Serial.Read();
uint8_t buf [VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if(x=='1′)
{
Als (vw_get_message (buf, & buflen))
{
voor (ik = 0; ik < buflen; i ++)
{
StringReceived [i] = char(buf[i]);
}
sscanf (StringReceived, "%d, %d", & sicaklik, & nem);
Serial.println(sicaklik);
delay(500);
Serial.println(NEM);
delay(500);
memset (StringReceived, 0, sizeof (StringReceived));
}
}
}