本帖最後由 超新手 於 2018-5-7 16:09 編輯  
 
看來你對陣列處理有點困難 
原因出在它的輸出是一維陣列, 並不是二維陣列 
所以我把程式改一下, 讓它變成二維陣列 
照理說, 值輸出應該是相同的, 有問題再告知 
- #include <Wire.h>
 
 - #include <Adafruit_AMG88xx.h> 
 
 - Adafruit_AMG88xx amg;
 
 - float pixels[8][8];
 
 - void setup() {
 
 -   Serial.begin(9600);
 
 -   Serial.println(F("AMG88xx pixels"));
 
 -   bool status;
 
 -   // default settings
 
 -   status = amg.begin();
 
 -   if (!status) {
 
 -     Serial.println("Could not find a valid AMG88xx sensor, check wiring!");
 
 -     while (1);
 
 -   }
 
 -   Serial.println("-- Pixels Test --");
 
 -   Serial.println();
 
 -   delay(100); // let sensor boot up
 
 - }
 
 - void loop() {
 
 -   //read all the pixels
 
 -   amg.readPixels(&pixels[0][0]);
 
 -   Serial.print("[");
 
 -   for (int i = 0; i < 8; i++) {
 
 -     for (int j = 0; j < 8; j++) {
 
 -       Serial.print(pixels[i][j]);
 
 -       Serial.print(", ");
 
 -     }
 
 -     Serial.println();
 
 -   }
 
 -   Serial.println("]");
 
 -   Serial.println();
 
 - // 和中心點pixels[5][5]的差值  
 
 -   Serial.print(pixels[4][4] - pixels[5][5]);Serial.print(" ");
 
 -   Serial.print(pixels[4][5] - pixels[5][5]);Serial.print(" ");
 
 -   Serial.println(pixels[4][6] - pixels[5][5]);
 
 -   Serial.print(pixels[5][4] - pixels[5][5]);Serial.print(" ");
 
 -   Serial.print(pixels[5][5] - pixels[5][5]);Serial.print(" ");
 
 -   Serial.println(pixels[5][6] - pixels[5][5]);
 
 -   Serial.print(pixels[6][4] - pixels[5][5]);Serial.print(" ");
 
 -   Serial.print(pixels[6][5] - pixels[5][5]);Serial.print(" ");
 
 -   Serial.println(pixels[6][6] - pixels[5][5]);  
 
  
-   //delay a second
 
 -   delay(1000);
 
 - }
 
  複製代碼 
 
經過修改後, 如果你要處理 pixels[5][5] 的值 
3x3 的陣列就是 
pixels[4][4], pixels[4][5], pixels[4][6], 
pixels[5][4], pixels[5][5], pixels[5][6], 
pixels[6][4], pixels[6][5], pixels[6][6], 
看你要怎樣運算都可以, 也比較直覺 
 
 
 
 
 |