时使用了不兼容的类型

时使用了不兼容的类型

本文介绍了在将"int"分配为"int [2]"时使用了不兼容的类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Arduino中,我有一个错误.

In Arduino I have an error.

long received;
long received_t;
long received_m;
int arra[2];

void setup() {
    analogReference(INTERNAL);
    Serial.begin(9600);
}

void loop() {
     while( Serial.available() > 0) {
         arra = Serial.read();
         Serial.println(arra[0]);
         Serial.println(arra[1]);
     }
}

推荐答案

如何

 while( Serial.available() > 1) {
     arra[0] = Serial.read();
     arra[1] = Serial.read();
     Serial.println(arra[0]);
     Serial.println(arra[1]);
 }

?

仍然不是好的代码,但至少应该编译.

Still not good code, but should at least compile.

这篇关于在将"int"分配为"int [2]"时使用了不兼容的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:38