Robofun 機器人論壇
標題:
想請問有關陣列的問題
[打印本頁]
作者:
lucy5222
時間:
2018-5-25 14:40
標題:
想請問有關陣列的問題
大家好目前在做陣列的研究,遇到了一些麻煩,在關於陣列要編譯時,沒辦法編譯,想請問大家那裡有問題 謝謝
#include <Wire.h>
#include <Adafruit_AMG88xx.h>
Adafruit_AMG88xx amg;
float pixels[AMG88xx_PIXEL_ARRAY_SIZE];
float pixels[8][8];
void setup()
{
Serial.begin(115200);
bool status;
status = amg.begin();
if (!status) {}
delay(100);
}
void loop()
{
amg.readPixels(pixels);
for (int i=1; i<=AMG88xx_PIXEL_ARRAY_SIZE; i++)
{
Serial.print('C');
Serial.print(pixels[i-1]);
while (Serial.available()<=0) {}
Serial.read();
}
amg.readPixels(&pixels[0][0]);
//第一列
Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[0][0])); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[0][1])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[0][1])); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[1][1])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[1][0])); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[1][0])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[0][0])); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[0][0])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][0] - pixels[0][0]));
for (int i = 0; i < 1; i++) {
for (int j = 1; j < 7; j++) {
Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i][j])); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i][j+1])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i][j+1])); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i+1][j+1])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i+1][j])); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i+1][j-1])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i][j-1])); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i][j-1])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[i][j] - pixels[i][j]));
}
}
Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][7])); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][7])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][7])); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[1][7])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[1][6])); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][7])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][6])); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][6])/sqrt(2),2); Serial.print("ab");
Serial.print(abs(pixels[0][7] - pixels[0][7]));
}
作者:
超新手
時間:
2018-5-25 14:55
本帖最後由 超新手 於 2018-5-25 14:56 編輯
兩個不同的陣列, 但名稱一樣
一個是一維陣列, 另一個是二維陣列
float pixels[AMG88xx_PIXEL_ARRAY_SIZE];
float pixels[8][8];
去掉其中一個即可,
當然和它相應的程式也要一併拿掉
歡迎光臨 Robofun 機器人論壇 (https://robofun.net/forum/)
Powered by Discuz! X3.2