byte incomingByte;// 用來儲存收進來的 data byte byte receive[12];//byte陣列 裡面儲存接收到的資料 boolean newLineReceived = false;// 是否已收到換行字元 void setup() { Serial.begin(9600);//Mega2560監控鮑率 Serial1.begin(2400);//與傳送板子溝通鮑率 } void loop() { //將得到的陣列值印出 for(int i=0;i<2;i+1) { Serial.print("current1:"); Serial.print(receive[i]); Serial.println(receive[i+1]); } for(int j=2;j<4;j+1) { Serial.print("current2:"); Serial.print(receive[j]); Serial.println(receive[j+1]); } for(int k=4;k<6;k+1) { Serial.print("temperature1:"); Serial.print(receive[k]); Serial.println(receive[k+1]); } for(int l=6;l<8;l+1) { Serial.print("temperature2:"); Serial.print(receive[l]); Serial.println(receive[l+1]); } for(int m=8;m<10;m+1) { Serial.print("voltage1:"); Serial.print(receive[m]); Serial.println(receive[m+1]); } for(int n=10;n<12;n+1) { Serial.print("voltage2:"); Serial.print(receive[n]); Serial.println(receive[n+1]); } } void serialEvent() { while (Serial1.available())//是否有傳值進入 { incomingByte = Serial1.read();// 把讀取的值 放在incomingByte for(int o=0;o<12;o++) { receive[o] += incomingByte;//將資料存入receive陣列 } if (incomingByte == '\n')//以換行字元得知是否收到完整封包 { newLineReceived = true; } } }
Standard input is empty
prog.c:1:1: error: unknown type name ‘byte’
byte incomingByte;// 用來儲存收進來的 data byte
^~~~
prog.c:2:1: error: unknown type name ‘byte’
byte receive[12];//byte陣列 裡面儲存接收到的資料
^~~~
prog.c:3:1: error: unknown type name ‘boolean’
boolean newLineReceived = false;// 是否已收到換行字元
^~~~~~~
prog.c:3:27: error: ‘false’ undeclared here (not in a function)
boolean newLineReceived = false;// 是否已收到換行字元
^~~~~
prog.c: In function ‘setup’:
prog.c:6:1: error: ‘Serial’ undeclared (first use in this function)
Serial.begin(9600);//Mega2560監控鮑率
^~~~~~
prog.c:6:1: note: each undeclared identifier is reported only once for each function it appears in
prog.c:7:1: error: ‘Serial1’ undeclared (first use in this function)
Serial1.begin(2400);//與傳送板子溝通鮑率
^~~~~~~
prog.c: In function ‘loop’:
prog.c:12:20: warning: statement with no effect [-Wunused-value]
for(int i=0;i<2;i+1)
~^~
prog.c:14:4: error: ‘Serial’ undeclared (first use in this function)
Serial.print("current1:");
^~~~~~
prog.c:18:19: warning: statement with no effect [-Wunused-value]
for(int j=2;j<4;j+1)
~^~
prog.c:24:19: warning: statement with no effect [-Wunused-value]
for(int k=4;k<6;k+1)
~^~
prog.c:30:19: warning: statement with no effect [-Wunused-value]
for(int l=6;l<8;l+1)
~^~
prog.c:36:20: warning: statement with no effect [-Wunused-value]
for(int m=8;m<10;m+1)
~^~
prog.c:42:21: warning: statement with no effect [-Wunused-value]
for(int n=10;n<12;n+1)
~^~
prog.c: In function ‘serialEvent’:
prog.c:51:10: error: ‘Serial1’ undeclared (first use in this function)
while (Serial1.available())//是否有傳值進入
^~~~~~~
prog.c:60:27: error: ‘true’ undeclared (first use in this function)
newLineReceived = true;
^~~~
Standard output is empty