byte sensor[12];//感測值儲存陣列 int i,j,k,l,m,n; void setup() { Serial.begin(2400);//與接收板子溝通鮑率 } void loop() { wcs1800();//電流感測 temperature();//溫度感測 voltage();//電壓感測 send_1();//Nano觀察 //transmit();//傳至Mega2560 } void wcs1800(void)//電流感測 { int A = analogRead(A5);//讀取電流感測1號的傳感值 int B = analogRead(A1);//讀取電流感測2號的傳感值 uint8_t AmpHigh01 = A >>8;//取高位元組 uint8_t AmpLow01 = A & 0xff;//取低位元組 sensor[0] = AmpHigh01; sensor[1] = AmpLow01; uint8_t AmpHigh02 = B >>8;//取高位元組 uint8_t AmpLow02 = B & 0xff;//取低位元組 sensor[2] = AmpHigh02; sensor[3] = AmpLow02; } void temperature(void)//溫度感測 { int C = analogRead(A2);//讀取溫度感測1號的傳感值 int D = analogRead(A3);//讀取溫度感測2號的傳感值 uint8_t TempHigh01 = C >>8;//取高位元組 uint8_t TempLow01 = C & 0xff;//取低位元組 sensor[4] = TempHigh01; sensor[5] = TempLow01; uint8_t TempHigh02 = D >>8;//取高位元組 uint8_t TempLow02 = D & 0xff;//取低位元組 sensor[6] = TempHigh02; sensor[7] = TempLow02; } void voltage(void)//電壓感測 { int E = analogRead(A4);//讀取電壓感測1號的傳感值 int F = analogRead(A6);//讀取電壓感測2號的傳感值 uint8_t VolHigh01 = E >>8;//取高位元組 uint8_t VolLow01 = E & 0xff;//取低位元組 sensor[8] = VolHigh01; sensor[9] = VolLow01; uint8_t VolHigh02 = F >>8;//取高位元組 uint8_t VolLow02 = F & 0xff;//取低位元組 sensor[10] = VolHigh02; sensor[11] = VolLow02; } void send_1(void)//Nano觀察 { for(i=0;i<2;i+1) { Serial.print("current1:"); Serial.print(sensor[i],BIN); Serial.print(" "); Serial.println(sensor[i+1],BIN); } for(j=2;j<4;j+1) { Serial.print("current2:"); Serial.print(sensor[j],BIN); Serial.print(" "); Serial.println(sensor[j+1],BIN); } for(k=4;k<6;k+1) { Serial.print("temperature1:"); Serial.print(sensor[k],BIN); Serial.print(" "); Serial.println(sensor[k+1],BIN); } for(l=6;l<8;l+1) { Serial.print("temperature2:"); Serial.print(sensor[l],BIN); Serial.print(" "); Serial.println(sensor[l+1],BIN); } for(m=8;m<10;m+1) { Serial.print("voltage1:"); Serial.print(sensor[m],BIN); Serial.print(" "); Serial.println(sensor[m+1],BIN); } for(n=10;n<12;n+1) { Serial.print("voltage2:"); Serial.print(sensor[n],BIN); Serial.print(" "); Serial.println(sensor[n+1],BIN); } } void transmit(void)//傳至Mega2560 { for(i=0;i<2;i+1) { Serial.write("current1:"); Serial.write(sensor[i]); Serial.write(sensor[i+1]); Serial.write(10); } for(j=2;j<4;j+1) { Serial.write("current2:"); Serial.write(sensor[j]); Serial.write(sensor[j+1]); Serial.write(10); } for(k=4;k<6;k+1) { Serial.write("temperature1:"); Serial.write(sensor[k]); Serial.write(sensor[k+1]); Serial.write(10); } for(l=6;l<8;l+1) { Serial.write("temperature2:"); Serial.write(sensor[l]); Serial.write(sensor[l+1]); Serial.write(10); } for(m=8;m<10;m+1) { Serial.write("voltage1:"); Serial.write(sensor[m]); Serial.write(sensor[m+1]); Serial.write(10); } for(n=10;n<12;n+1) { Serial.write("voltage2:"); Serial.write(sensor[n]); Serial.write(sensor[n+1]); Serial.write(10); } }
Standard input is empty
prog.c:1:1: error: unknown type name ‘byte’
byte sensor[12];//感測值儲存陣列
^~~~
prog.c: In function ‘setup’:
prog.c:5:1: error: ‘Serial’ undeclared (first use in this function)
Serial.begin(2400);//與接收板子溝通鮑率
^~~~~~
prog.c:5:1: note: each undeclared identifier is reported only once for each function it appears in
prog.c: In function ‘loop’:
prog.c:9:2: warning: implicit declaration of function ‘wcs1800’ [-Wimplicit-function-declaration]
wcs1800();//電流感測
^~~~~~~
prog.c:10:2: warning: implicit declaration of function ‘temperature’ [-Wimplicit-function-declaration]
temperature();//溫度感測
^~~~~~~~~~~
prog.c:11:2: warning: implicit declaration of function ‘voltage’ [-Wimplicit-function-declaration]
voltage();//電壓感測
^~~~~~~
prog.c:12:2: warning: implicit declaration of function ‘send_1’ [-Wimplicit-function-declaration]
send_1();//Nano觀察
^~~~~~
prog.c: At top level:
prog.c:15:6: warning: conflicting types for ‘wcs1800’
void wcs1800(void)//電流感測
^~~~~~~
prog.c:9:2: note: previous implicit declaration of ‘wcs1800’ was here
wcs1800();//電流感測
^~~~~~~
prog.c: In function ‘wcs1800’:
prog.c:17:10: warning: implicit declaration of function ‘analogRead’ [-Wimplicit-function-declaration]
int A = analogRead(A5);//讀取電流感測1號的傳感值
^~~~~~~~~~
prog.c:17:21: error: ‘A5’ undeclared (first use in this function)
int A = analogRead(A5);//讀取電流感測1號的傳感值
^~
prog.c:18:21: error: ‘A1’ undeclared (first use in this function)
int B = analogRead(A1);//讀取電流感測2號的傳感值
^~
prog.c:19:2: error: unknown type name ‘uint8_t’
uint8_t AmpHigh01 = A >>8;//取高位元組
^~~~~~~
prog.c:20:2: error: unknown type name ‘uint8_t’
uint8_t AmpLow01 = A & 0xff;//取低位元組
^~~~~~~
prog.c:23:2: error: unknown type name ‘uint8_t’
uint8_t AmpHigh02 = B >>8;//取高位元組
^~~~~~~
prog.c:24:2: error: unknown type name ‘uint8_t’
uint8_t AmpLow02 = B & 0xff;//取低位元組
^~~~~~~
prog.c: At top level:
prog.c:28:6: warning: conflicting types for ‘temperature’
void temperature(void)//溫度感測
^~~~~~~~~~~
prog.c:10:2: note: previous implicit declaration of ‘temperature’ was here
temperature();//溫度感測
^~~~~~~~~~~
prog.c: In function ‘temperature’:
prog.c:30:21: error: ‘A2’ undeclared (first use in this function)
int C = analogRead(A2);//讀取溫度感測1號的傳感值
^~
prog.c:31:21: error: ‘A3’ undeclared (first use in this function)
int D = analogRead(A3);//讀取溫度感測2號的傳感值
^~
prog.c:32:2: error: unknown type name ‘uint8_t’
uint8_t TempHigh01 = C >>8;//取高位元組
^~~~~~~
prog.c:33:2: error: unknown type name ‘uint8_t’
uint8_t TempLow01 = C & 0xff;//取低位元組
^~~~~~~
prog.c:36:2: error: unknown type name ‘uint8_t’
uint8_t TempHigh02 = D >>8;//取高位元組
^~~~~~~
prog.c:37:2: error: unknown type name ‘uint8_t’
uint8_t TempLow02 = D & 0xff;//取低位元組
^~~~~~~
prog.c: At top level:
prog.c:41:6: warning: conflicting types for ‘voltage’
void voltage(void)//電壓感測
^~~~~~~
prog.c:11:2: note: previous implicit declaration of ‘voltage’ was here
voltage();//電壓感測
^~~~~~~
prog.c: In function ‘voltage’:
prog.c:43:21: error: ‘A4’ undeclared (first use in this function)
int E = analogRead(A4);//讀取電壓感測1號的傳感值
^~
prog.c:44:21: error: ‘A6’ undeclared (first use in this function)
int F = analogRead(A6);//讀取電壓感測2號的傳感值
^~
prog.c:45:2: error: unknown type name ‘uint8_t’
uint8_t VolHigh01 = E >>8;//取高位元組
^~~~~~~
prog.c:46:2: error: unknown type name ‘uint8_t’
uint8_t VolLow01 = E & 0xff;//取低位元組
^~~~~~~
prog.c:49:2: error: unknown type name ‘uint8_t’
uint8_t VolHigh02 = F >>8;//取高位元組
^~~~~~~
prog.c:50:2: error: unknown type name ‘uint8_t’
uint8_t VolLow02 = F & 0xff;//取低位元組
^~~~~~~
prog.c: At top level:
prog.c:54:6: warning: conflicting types for ‘send_1’
void send_1(void)//Nano觀察
^~~~~~
prog.c:12:2: note: previous implicit declaration of ‘send_1’ was here
send_1();//Nano觀察
^~~~~~
prog.c: In function ‘send_1’:
prog.c:56:15: warning: statement with no effect [-Wunused-value]
for(i=0;i<2;i+1)
~^~
prog.c:58:4: error: ‘Serial’ undeclared (first use in this function)
Serial.print("current1:");
^~~~~~
prog.c:59:27: error: ‘BIN’ undeclared (first use in this function)
Serial.print(sensor[i],BIN);
^~~
prog.c:63:15: warning: statement with no effect [-Wunused-value]
for(j=2;j<4;j+1)
~^~
prog.c:70:15: warning: statement with no effect [-Wunused-value]
for(k=4;k<6;k+1)
~^~
prog.c:77:15: warning: statement with no effect [-Wunused-value]
for(l=6;l<8;l+1)
~^~
prog.c:84:16: warning: statement with no effect [-Wunused-value]
for(m=8;m<10;m+1)
~^~
prog.c:91:17: warning: statement with no effect [-Wunused-value]
for(n=10;n<12;n+1)
~^~
prog.c: In function ‘transmit’:
prog.c:101:15: warning: statement with no effect [-Wunused-value]
for(i=0;i<2;i+1)
~^~
prog.c:103:4: error: ‘Serial’ undeclared (first use in this function)
Serial.write("current1:");
^~~~~~
prog.c:108:15: warning: statement with no effect [-Wunused-value]
for(j=2;j<4;j+1)
~^~
prog.c:115:15: warning: statement with no effect [-Wunused-value]
for(k=4;k<6;k+1)
~^~
prog.c:122:15: warning: statement with no effect [-Wunused-value]
for(l=6;l<8;l+1)
~^~
prog.c:129:16: warning: statement with no effect [-Wunused-value]
for(m=8;m<10;m+1)
~^~
prog.c:136:17: warning: statement with no effect [-Wunused-value]
for(n=10;n<12;n+1)
~^~
Standard output is empty