|
各位大大好~
最近我在學arduino的programming, 下面問題令我苦思了一段時間也沒有DEL不了BUG
下面的CODE我想把arrary內的a和b轉成4,0,3,0四個數字, 然後把四個數字順序和放入Step00.Step01,Step02,Step03內...
但是卻改不到想要的結果...有大大看到BUG在那嗎?
PS.為什麼我打char StepBuff[10]改成int StepBuff[10]就有BUG出現~
- char Step00;char Step01;char Step02;char Step03;char StepBuff[10];const byte cmmd = 32;char ReceivedChars[cmmd] = {'a', 'b'};int c =0;
- void setup() { Serial.begin(9600); Serial.println("<Ardunio & Display is ready>");}
- void loop() { while (c == 0){ MappingChars(); LoadingDegree(); Serial.print("The value of StepBuff is"); Serial.println(StepBuff); Serial.print("The value of Step00 is"); Serial.println(Step00); Serial.print("The value of Step01 is"); Serial.println(Step01); c++;}}
- void MappingChars(){for(int i=0; i<2; i++){if (ReceivedChars[i] = 'a'){StepBuff[i] = 4;i++;StepBuff[i] = 0;i--;}
- if (ReceivedChars[i] = 'b'){StepBuff[i] = 3;i++;StepBuff[i] = 0;i--;}}}
- void LoadingDegree(){
- for(int k=0; k<4; k++){ if (StepBuff[k] == 0 && k == 0){Step00 = StepBuff[k];}
- if (StepBuff[k] == 4 && k == 0){Step00 = StepBuff[k];}}}
複製代碼 |
|