Varible Conversion & Serial question
im trying send incomming serial message on rf. when try compile code error like: invailed conversion int const char*
and highlights line:
i have tried use char(serial.read());
but compiler tells me cannot convert char const char*
so removed const since isn't contante (i think) still error because of "*" (star)
i want put incomming serial message msg
anyway please note using virtualwire , therfore have trouble when chaning var type of msg
my total code:
thanks alot
nick
and highlights line:
code: [select]
const char* msg = serial.read();i have tried use char(serial.read());
but compiler tells me cannot convert char const char*
so removed const since isn't contante (i think) still error because of "*" (star)
i want put incomming serial message msg
anyway please note using virtualwire , therfore have trouble when chaning var type of msg
my total code:
code: [select]
#include <virtualwire.h>
void setup()
{
//setup virtualwire transmit on 4
vw_setup(100);
vw_set_tx_pin(4);
pinmode(13, output); //power led
digitalwrite(13, high); //always on
//setup serial connection
serial.begin(9600);
}
void loop()
{
if(serial.available() > 0)
{
const char* msg = serial.read();
if(*msg != 'for' ||
*msg != 'bac' ||
*msg != 'lef' ||
*msg != 'rig' ||
*msg != 'xxx')
{serial.println("error sending:");serial.println(msg);}
else
{
vw_send((uint8_t *)msg, strlen(msg));
}
}
}thanks alot

nick
serial.read returns single int, not pointer char.
Arduino Forum > Using Arduino > Programming Questions > Varible Conversion & Serial question
arduino
Comments
Post a Comment