Arduino 数组未命名类型

Tal*_* C. 0 c++ arrays types arduino arduino-uno

问题出在数组上。声明数组的那行没有问题,是它后面的那一行。似乎我无法像在 C 中那样编码。为了清晰起见,我如何在需要这种格式时修复它。我不想写很长的一行,因为这个数组中有 15 个变量。

这是代码

#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>

Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver();

#define SERVOMIN  150 // this is the 'minimum' pulse length count (out of 4096)
#define SERVOMAX  600 // this is the 'maximum' pulse length count (out of 4096)

///// void setup /////
void setup() {
  Serial.begin(9600);
  pwm.begin();
  pwm.setPWMFreq(60);  // Analog servos run at ~60 Hz updates
  delay(10);
}



///// Coordonnees /////
int angles[5][3];    //angles de chaque moteur pour chaque cube
angles[0][0]=60;
angles[0][1]=120;
angles[0][2]=100;
Run Code Online (Sandbox Code Playgroud)

基本上它angles[0][0]=;是导致问题的和与它相似的线。

Ser*_*eyA 5

在全局范围内只允许少数事情,并且赋值不是其中之一。

您可以声明或定义变量(并初始化它们),因此这就是您可以定义数组的原因。实现目标的一种方法是初始化数组,而不是为其赋值:

int angles[5][3] {
                  {1, 2, 3},
                  {3, 4, 5},
                  {5, 6, 7},
                  {8, 9, 10},
                  {11, 12, 13}
                 };
Run Code Online (Sandbox Code Playgroud)