Hey guys,
im working on a project to control two servos connected to the receiver arduino by 2 pots connected to the transmitter arduino.
I wanted to start by transmitting two 3 digit numbers across which would ultimately be stored as ints.
for now im just trying to send 2 of the same "Count" integer over separated by a comma.
This is the first time I've worked with the char data format and i need some guidance. Im totally lost trying to figure out how to combine these two ints along with a comma to be sent over. So far all i have is the int "count" being received.
coul someone point me in the right direction :-[
Thanks guys
Heres the code
Transmitter
// Transmitter V0.1
// V0.0 - Transmit string to receiver
// V0.1 - Transmit count string to receiver
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
int count = 0;
char *msg;
char num1[3];
void setup()
{
vw_set_ptt_inverted(true);
vw_setup(4800);
vw_set_tx_pin(3); // Transmitter Data Pin
}
void loop()
{
count++;
itoa(count, num1, 10);
char *msg=num1;
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
delay(50);
if(count == 999)
{
count=0;
}
}
Receiver
// Receiver V0.1
// V0.0 - Receive string from transmitter then print string on serial port
// V0.1 - Receive string from transmitter, save in "received" string then print "received" string
#include <VirtualWire.h>
#undef int
#undef abs
#undef double
#undef float
#undef round
char received[100];
void setup()
{
Serial.begin(9600);
vw_set_ptt_inverted(true);
vw_setup(4800);
vw_set_rx_pin(23); // Receiver Data Pin
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))
{
int i;
for (i = 0; i < buflen; i++)
{
received[i]=buf[i];
}
Serial.println(received);
}
}