我需要一種方法來檢查這些引腳以正確的順序從高電平變爲低電平。 (即紅色>棕色>藍色>灰色>黑色>黃色>白色>橙色>紫色>綠色)如果其中一個引腳變爲亂序,如果錯誤計數超過4則必須將「errorCount」加1,然後調用函數。對於銷的代碼如何檢查值是否按正確順序變化? C++
部分:
const int wire_BROWN = 30;
int wire_BROWN_state = 0;
int wire_BROWN_lastState = 0;
const int wire_RED = 32;
int wire_RED_state = 0;
int wire_RED_lastState = 0;
const int wire_ORANGE = 34;
int wire_ORANGE_state = 0;
int wire_ORANGE_lastState = 0;
const int wire_YELLOW = 36;
int wire_YELLOW_state = 0;
int wire_YELLOW_lastState = 0;
const int wire_GREEN = 38;
int wire_GREEN_state = 0;
int wire_GREEN_lastState = 0;
const int wire_BLUE = 40;
int wire_BLUE_state = 0;
int wire_BLUE_lastState = 0;
const int wire_PURPLE = 42;
int wire_PURPLE_state = 0;
int wire_PURPLE_lastState = 0;
const int wire_GREY = 44;
int wire_GREY_state = 0;
int wire_GREY_lastState = 0;
const int wire_WHITE = 46;
int wire_WHITE_state = 0;
int wire_WHITE_lastState = 0;
const int wire_BLACK = 48;
int wire_BLACK_state = 0;
int wire_BLACK_lastState = 0;
設置一個有限狀態機。 –