Getting this error: incompatible types in assignment of 'int' to 'char [16]'

Hi there,

I'm struggling to add a certain string (or char[]) to an array of struct because of the error on the top. I would appreciate it so much if I could get some help with this. The problem is on the line "channels[i].create = Serial.read();".

Code:

#include <Wire.h>
#include <Adafruit_RGBLCDShield.h>
#include <utility/Adafruit_MCP23017.h>

Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();


#define LIMIT 27

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

char c;

protocol channels[LIMIT];

void create_channels() {
  int i = 0;

  while (Serial.available() > 0)
  {
    channels[i].create = Serial.read();
    i++;
    if (i != 0)
    {
      Serial.println((String)"Channel description: " + channels[i].create);
    }
  }
}

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  lcd.begin(16, 2);
}

Serial.read returns an int, but you're trying to assign that int to an array.

channels[i].create [someIndexHere]= Serial.read();

Your code lacks a loop function

Ooooh I see. So could I add a loop with an index that goes from 0-25 that has 26 different values?

No, because that array has only 16 elements

Interesting...

My only issue is trying to make it work like:

an-array-of-structure-1504600972923

Do you have any tips?

I don't know what it is you're trying to do.
The diagram you posted doesn't seem to relate to the code you posted.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.