Hello,
This comes from a newbie. I am using the Virtual wire library to transmit (through a 433 MHz transmitter) in a loop a character at time 0, 1... 9 and the string "End" at the end of the loop:
#include <VirtualWire.h>
void setup()
{
Serial.begin(9600);
Serial.println("setup");
vw_set_tx_pin (12);
vw_setup(1000);
}
void loop()
{
char msg[27];
for (int i=0; i <= 9; i++){
sprintf(msg, "%i", i);
digitalWrite(13, true);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println(i);
digitalWrite(13, false);
delay(1000);
}
sprintf(msg, "End");
digitalWrite(13, true);
vw_send((uint8_t *)msg, strlen(msg));
vw_wait_tx();
Serial.println(msg);
digitalWrite(13, false);
delay(1000);
}
Then, through another Arduino, I have a 433 MHz receiver end a 16x2 LCD attached. I am having success to display the number from 0 to 9 that I receive, but the string "End" only display the "E".
#include <VirtualWire.h>
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup()
{
lcd.begin(16, 2);
Serial.begin(9600); // Debugging only
Serial.println("setup");
lcd.print("setup");
vw_set_rx_pin (7);
vw_setup(1000);
vw_rx_start();
}
void loop()
{
uint8_t buf[VW_MAX_MESSAGE_LEN];
uint8_t buflen = VW_MAX_MESSAGE_LEN;
int i;
char msg;
if (vw_get_message(buf, &buflen))
{
lcd.clear();
digitalWrite(13, true);
Serial.print("Got: ");
Serial.write(msg);
Serial.println("");
lcd.setCursor(0,0);
lcd.print("Got:");
lcd.setCursor(0, 1);
msg = *buf;
lcd.print(msg);
digitalWrite(13, false);
}
}
I am having a hard time to understand the type uint8_t and its pointer and how I can convert buf into something that can be displayed with the function lcd.print. Can someone tell me what am I missing? How can I display on the LCD a longer (more than one character) string that comes from vw_get_message(buf, &buflen)?
Thanks a ton.
Test_Transmitter_433_VW.ino (584 Bytes)
LCD_Receiver_433_VM.ino (756 Bytes)