#include <VirtualWire.h>
int PWMB = 5; //Speed control
void setup(){
Serial.begin(9600);
//receiver setup
vw_set_rx_pin(2);
vw_set_ptt_inverted(true);
vw_setup(2000);
vw_rx_start();
}
void loop(){
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
if (vw_get_message(buf, &buflen)) // Non-blocking
{
int i;
int column = 0;
String message;
int commands[30];
for (i = 0; i < buflen; i++)
{
//DEBUG:
Serial.print(char(buf[i]));
if(char(buf[i]) == '|'){
commands[column] = message.toInt();
message = "";
column++;
} else {
message += char(buf[i]);
}
}
commands[column] = message.toInt();
}
}
This topic is the receiver side of my last topic: please explain the sketch attached that one sending date and this is a receiver.
questions:
- The transmitter transfer date array of [60] like: 523 | 487, here
int commands[30];just 30, is it OK? if(char(buf[i]) == '|') / commands[column] = message.toInt();, seems just convert the date before '|'?- What is the result of
message += char(buf[i]);?
Thanks