title: How can I store values in an array of structs? - Arduino Uno
body: <p>I'm trying to make a struct of array where each index has its own set of properties. For example, I want channels[0].name to have its own name and channels[1].name to be different too.</p>
  <p>Each time I have a new input, the old one is forgotten and shows the new one repeatedly. I would really appreciate some tips.</p>
  <p>Part of the code:</p>
  <pre><code>
  #include &lt;Wire.h&gt;
  #include &lt;Adafruit_RGBLCDShield.h&gt;
  #include &lt;utility/Adafruit_MCP23017.h&gt;
  
  Adafruit_RGBLCDShield lcd = Adafruit_RGBLCDShield();
   #define LIMIT 26
   
   struct protocol {
    String name;
    char character;
    int values;
    int minimum;
    int maximum;
  };
  
  void create_channels() {
  String details;
  struct protocol channels[LIMIT];
  
  int i = 0;
  
  do {
         byte b = Serial.available();
          if (b != 0)
          {
            details = Serial.readStringUntil('\n');
            details.trim();
            if (details.startsWith(&quot;C&quot;)) {
              Serial.print(&quot;Channel description: &quot;);
              Serial.println(details);
              channels[i].name = details;
             for (i=0; i &lt; LIMIT; i++) {
              channels[i].name = details;
              Serial.println(channels[i].name);
              }
  
            } else if (details.startsWith(&quot;V&quot;)) {
              
            } else if (details.startsWith(&quot;X&quot;)) {
              
            } else if (details.startsWith(&quot;N&quot;)) {
              
            }
             else {
              Serial.println(&quot;Invalid character&quot;);
            }
          }
        } while (1);
  }
  
  void setup() {
    // put your setup code here, to run once:
    lcd.begin(16, 2);
    Serial.begin(9600);
    Serial.setTimeout(10);
    lcd.setBacklight(7);
  
  create_channels();
  
  
  }
  
  void loop() {
   
  }
  </code></pre>
  <p>This is the result:</p>
  <pre><code>Channel description: CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  CAMain
  Channel description: CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  CBSecondary
  </code></pre>