PaulS:
struct
{
int timerSeconds;
int ab;
int blank;
int endbuzz;
int pretimer;
int green;
int red;
int currentState;
} MyStruct;
A struct is useful when it contains different types. An array makes more sense when the types are all the same.
if (int(key) != 0 and currentState == 1) {
Why did you feel it necessary to cast a char to an int so you could compare it to 0?
Are there really enough states to warrant currentState being an int?
if (ab = 0);{
Two major mistakes in only 14 characters. Must be some kind of record.
tempVal[0] = currentTimeValue[0];
tempVal[1] = currentTimeValue[1];
tempVal[2] = currentTimeValue[2];
tempVal[3] = 0;
Writing beyond the end of an array is stupid.
tempVal[1] = 0;
checkmin = atol(tempVal);
if (checkmin > 3) {
clearScreen();
lcd.setCursor(0,0);
lcd.print("ILLEGAL TIME");
delay(2000);
currentTimeValue[0]='0';
currentTimeValue[1]='0';
currentTimeValue[2]='0';
currentState = 1;
displayCodeEntryScreen();
}
senddata();
Your
indenting
sucks.
if (currentState == 3) {
senddata();
showpretimer();
delay(1000);
--pretimer;{
if (pretimer == 0 ){
currentState = 4; //startbuzz state
}
}
}
Big
time.
lcd.setCursor(13,1);
Row 13?
bool ok = radio.write( &MyStruct, sizeof(MyStruct) );
What is the purpose of sending this struct, when you have not written any data to it?
joeblogs:
al in all a pretty f....... valiant attempt.
have you had any part of the code working in pieces, you might want to start and get one single piece working ie. send some info through a communication stream.
i have NILL idea about RF but in the protocols(communication) ive seen only 1 byte can get sent ie (1,0,1,0,1,0,1,0) not a whole struct, i could be wrong in assumming, but i imaging that RF is no different.
Hi All,
Yes the serial printing was done for fault finding - all the data is working via Serial.print(variable) so I thouight I would add it to the struct - isn't that what I did when I defined the structure - does it not pick up the defined values?
Yes all the code so far works a treat - don't knock the keypad code - I stole it from somewhere else.
I am having real trouble getting the radio to send data - does this mean I have to populate the data in the struct first?
I would have thought I would have got a lot of zeros if it was not populated with data. Hoever my real problem appears that the radio does not receive any data - yet they work fine with the getting started example sketch. So I thought it must be linked somewhere around this.
Thanks for the critique to all - yes my indenting probably does suck - I am not a professional - just dabbling.
I have spent a lot of time on this to date. The countdown timer works nicely and does everything I need it to do, all I want to do now is transfer the data to the receiver and decode it do a second hand HUGE seven Seg archery timer display (dead micro).
My thought on using the struct was to be able to transfer it in one hit and then decode the data at the other end as per some examples on the web.
Thanks so far..
Cheers
Warren.