首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Arduino VirtualWire射频模块发送字符串

Arduino VirtualWire射频模块发送字符串
EN

Stack Overflow用户
提问于 2014-09-30 09:35:10
回答 1查看 4.8K关注 0票数 1

抱歉,如果我的帖子格式不好,我是新来的。

代码语言:javascript
复制
/*
    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
}
EN

回答 1

Stack Overflow用户

发布于 2014-11-15 13:52:30

char *message表示字符串文字或字符指针,但传递给函数的是字符串。您可以使用以下命令对其进行修复:

代码语言:javascript
复制
char Mensagem[]= "eureca";

以便匹配类型。这是因为Mensagem现在是字符数组的静态指针。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26111439

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档