抱歉,如果我的帖子格式不好,我是新来的。
/*
SimpleSend
This sketch transmits a short text message using the VirtualWire library
connect the Transmitter data pin to Arduino pin 12
*/
#include <VirtualWire.h>
String Mensagem = "eureca"; //I want to send this string
void setup(){
// Initialize the IO and ISR
vw_setup(2000); // Bits per sec
}
void loop(){
send(Mensagem); //Putting a string inside the function does not work,
//I want to send a String message inside that function like a parameter
delay(1000);
}
void send (char *message){
vw_send((uint8_t *)message, strlen(message));
vw_wait_tx(); // Wait until the whole message is gone
}发布于 2014-11-15 13:52:30
char *message表示字符串文字或字符指针,但传递给函数的是字符串。您可以使用以下命令对其进行修复:
char Mensagem[]= "eureca";以便匹配类型。这是因为Mensagem现在是字符数组的静态指针。
https://stackoverflow.com/questions/26111439
复制相似问题