This is my code:
struct command {
int hour, minute;
char action;
};
struct command list[1];
void setup() {
list[0] = {12, 50, 'u'};
list[1] = {13, 0, 's'};
Serial.begin(9600);
}
void loop() {
Serial.println(String(list[0].hour) + ":" + String(list[0].minute) + " " + list[0].action);
Serial.println(String(list[1].hour) + ":" + String(list[1].minute) + " " + list[1].action);
}
I want the output to be:
12:50 u
13:0 s
12:50 u
13:0 s
....
But the output is:
12:50 u
13:0 s
12:50 u
13:0 s
12:50 u
14:0 v
12:50 u
15:0 y
12:50 u
25:0
12:50 u
42:0 M
12:50 u
60:0
12:50 u
77:0 9
....
Do you guys know what is my problem?
Thanks
noiasca
3
list[0] and list[1] are two elements.
struct command {
int hour, minute;
char action;
};
struct command list[2];
void setup() {
Serial.begin(115200);
Serial.println("test");
list[0] = {12, 50, 'u'};
list[1] = {13, 0, 's'};
}
void loop() {
Serial.println(String(list[0].hour) + ":" + String(list[0].minute) + " " + list[0].action);
Serial.println(String(list[1].hour) + ":" + String(list[1].minute) + " " + list[1].action);
delay(1000);
}
edit: to late - but,...
UKHeliBob:
struct command list[1];
An array of one struct
noiasca:
list[0] and list[1] are two elements.
struct command {
int hour, minute;
char action;
};
struct command list[2];
void setup() {
Serial.begin(115200);
Serial.println("test");
list[0] = {12, 50, 'u'};
list[1] = {13, 0, 's'};
}
void loop() {
Serial.println(String(list[0].hour) + ":" + String(list[0].minute) + " " + list[0].action);
Serial.println(String(list[1].hour) + ":" + String(list[1].minute) + " " + list[1].action);
delay(1000);
}
edit: to late - but,...
Thanks!