I'm developing a little struct to hold some data for my sprinkler controller, which uses the T3.1 and Wiznet 820io (great stuff!).
But, just a setup() which sets the values and a loop which prints them out kicks out of memory errors after less than a minute of running.
It's probably something simple, but I can't see what the issue might be - any ideas?
But, just a setup() which sets the values and a loop which prints them out kicks out of memory errors after less than a minute of running.
It's probably something simple, but I can't see what the issue might be - any ideas?
Code:
#include <Flash.h>
enum {front=8,back=9};
struct zone_t {
byte pPin;
byte pState;
byte pDuration;
unsigned long pOnAtMillis;
byte pEnabled;
struct slot_t {
byte iHour;
byte iMin;
byte iDuration;
byte dayOfWeek[7];
} slot[2];
} zone[2];
void setup(){
Serial.begin(9600);
for (int i=0;i<2;i++){
zone[i].pPin = i+100;
zone[i].pState = i+110;
zone[i].pDuration = i+120;
zone[i].pOnAtMillis = i+130;
zone[i].pEnabled = i+140;
for (int j=0;j<2;j++){
zone[i].slot[j].iHour = j+200;
zone[i].slot[j].iMin = j+210;
zone[i].slot[j].iDuration = j+220;
for (int k=0;k<7;k++){
zone[i].slot[j].dayOfWeek[k] = k+300;
};
};
};
};
void loop(){
for (int i=0;i<2;i++){
Serial << "pPin: " << zone[i].pPin << " pState: " << zone[i].pState
<< " pDuration: " << zone[i].pDuration << " pOnAtMillis: " << zone[i].pOnAtMillis << " pEnabled: " << zone[i].pEnabled << "\n";
for (int j=0;j<2;j++){
Serial << "\tiHour: " << zone[i].slot[j].iHour << " iMin: " << zone[i].slot[j].iMin
<< " iDuration: " << zone[i].slot[j].iDuration << "\n";
for (int k=0;k<7;k++){
Serial << "\t\tDayOfWeek" << zone[i].slot[j].dayOfWeek[k] << "\t";
};
Serial << "\n";
};
Serial << "\n";
};
Serial << "\n";
};
Last edited: