int to char的Assigmnet中不兼容的类型[16]错误-Arduino uno

发布于 2025-01-24 18:00:46 字数 990 浏览 3 评论 0原文

我已经创建了一系列的结构,但是我会收到有关此问题标题的错误。我仍然是新手,所以我想知道我是否能得到一些帮助。

代码:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  lcd.begin(16, 2);
  i = 0;
}
#define LIMIT 27

struct protocol {
  char create[16];
  char character;
  int values;
  int minimum;
  int maximum;
};

struct protocol channels[LIMIT];
int i;

void create_channels() {
  if (Serial.available() > 0) {
    Serial.print("Enter the channel description");
    channels[i].create = Serial.read();
    Serial.print("Enter the starting character: ");
    channels[i].character = Serial.read();

    if (i == LIMIT) {
      for (i = 0; i < LIMIT; i++)
      {
        Serial.println(channels[i].create);
        Serial.println(channels[i].character);
      }
      i = 0;

    }
  }
}

错误:

cw.ino:24:38: error: incompatible types in assignment of 'int' to 'char [16]'
     channels[i].create = Serial.read();

I've created an array of structs but I'm getting the error written on the title of this question. I'm still new to this so I was wondering if I could get some help.

Code:

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  lcd.begin(16, 2);
  i = 0;
}
#define LIMIT 27

struct protocol {
  char create[16];
  char character;
  int values;
  int minimum;
  int maximum;
};

struct protocol channels[LIMIT];
int i;

void create_channels() {
  if (Serial.available() > 0) {
    Serial.print("Enter the channel description");
    channels[i].create = Serial.read();
    Serial.print("Enter the starting character: ");
    channels[i].character = Serial.read();

    if (i == LIMIT) {
      for (i = 0; i < LIMIT; i++)
      {
        Serial.println(channels[i].create);
        Serial.println(channels[i].character);
      }
      i = 0;

    }
  }
}

Error:

cw.ino:24:38: error: incompatible types in assignment of 'int' to 'char [16]'
     channels[i].create = Serial.read();

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文