Y
Y
Yuri2015-06-21 11:36:27
Arduino
Yuri, 2015-06-21 11:36:27

Arduino - how to use structures?

I've been struggling with structures all morning, a
simple sketch I took from the website
playground.arduino.cc/Code/Struct
compile error

struct RGB {
  byte r;
  byte g;
  byte b;
};

RGB variable = { 255 , 0 , 0 };

variable.r = 0; // здесь падает ошибка - test:10: error: 'variable' does not name a type

void setup() {}
void loop() {}

I also tried a dozen more struct / typedef options - they all end up with a similar assignment error.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
MiiNiPaa, 2015-06-21
@riky

Put variable.r = 0;in a function.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question