Hi,
(I may be missing something here too, but here comes the long winded answer....)
Since you have an array of 12 bytes each byte can only hold a value between 0 and 255. If you want a delay longer than 255mS you need to, either use an array of words OR use two bytes in the byte-array to 'make' a word.
The multiply by 256 "shifts" the 8 bits in DataIn[3] to the upper 8 bits in Delay1.
Say you want a 1000mS delay. Since 1000 wont fit in a byte you'll use two bytes. 1000 in binary is 00000011 11101000 so DataIn[3] = 3 and DataIn[4] = 232.
Then when you parse it you get Delay1 = DataIn[3] * 256 + DataIn[4] which is the same as 3 * 256 + 232 = 1000.
Or the easier way:
Delay1.HighByte = DataIn[3]
Delay1.LowByte = DataIn[4]
/Henrik Olsson.
Bookmarks