fork download
  1. byte sensor[12];//感測值儲存陣列
  2. int i,j,k,l,m,n;
  3. void setup()
  4. {
  5. Serial.begin(2400);//與接收板子溝通鮑率
  6. }
  7. void loop()
  8. {
  9. wcs1800();//電流感測
  10. temperature();//溫度感測
  11. voltage();//電壓感測
  12. send_1();//Nano觀察
  13. //transmit();//傳至Mega2560
  14. }
  15. void wcs1800(void)//電流感測
  16. {
  17. int A = analogRead(A5);//讀取電流感測1號的傳感值
  18. int B = analogRead(A1);//讀取電流感測2號的傳感值
  19. uint8_t AmpHigh01 = A >>8;//取高位元組
  20. uint8_t AmpLow01 = A & 0xff;//取低位元組
  21. sensor[0] = AmpHigh01;
  22. sensor[1] = AmpLow01;
  23. uint8_t AmpHigh02 = B >>8;//取高位元組
  24. uint8_t AmpLow02 = B & 0xff;//取低位元組
  25. sensor[2] = AmpHigh02;
  26. sensor[3] = AmpLow02;
  27. }
  28. void temperature(void)//溫度感測
  29. {
  30. int C = analogRead(A2);//讀取溫度感測1號的傳感值
  31. int D = analogRead(A3);//讀取溫度感測2號的傳感值
  32. uint8_t TempHigh01 = C >>8;//取高位元組
  33. uint8_t TempLow01 = C & 0xff;//取低位元組
  34. sensor[4] = TempHigh01;
  35. sensor[5] = TempLow01;
  36. uint8_t TempHigh02 = D >>8;//取高位元組
  37. uint8_t TempLow02 = D & 0xff;//取低位元組
  38. sensor[6] = TempHigh02;
  39. sensor[7] = TempLow02;
  40. }
  41. void voltage(void)//電壓感測
  42. {
  43. int E = analogRead(A4);//讀取電壓感測1號的傳感值
  44. int F = analogRead(A6);//讀取電壓感測2號的傳感值
  45. uint8_t VolHigh01 = E >>8;//取高位元組
  46. uint8_t VolLow01 = E & 0xff;//取低位元組
  47. sensor[8] = VolHigh01;
  48. sensor[9] = VolLow01;
  49. uint8_t VolHigh02 = F >>8;//取高位元組
  50. uint8_t VolLow02 = F & 0xff;//取低位元組
  51. sensor[10] = VolHigh02;
  52. sensor[11] = VolLow02;
  53. }
  54. void send_1(void)//Nano觀察
  55. {
  56. for(i=0;i<2;i+1)
  57. {
  58. Serial.print("current1:");
  59. Serial.print(sensor[i],BIN);
  60. Serial.print(" ");
  61. Serial.println(sensor[i+1],BIN);
  62. }
  63. for(j=2;j<4;j+1)
  64. {
  65. Serial.print("current2:");
  66. Serial.print(sensor[j],BIN);
  67. Serial.print(" ");
  68. Serial.println(sensor[j+1],BIN);
  69. }
  70. for(k=4;k<6;k+1)
  71. {
  72. Serial.print("temperature1:");
  73. Serial.print(sensor[k],BIN);
  74. Serial.print(" ");
  75. Serial.println(sensor[k+1],BIN);
  76. }
  77. for(l=6;l<8;l+1)
  78. {
  79. Serial.print("temperature2:");
  80. Serial.print(sensor[l],BIN);
  81. Serial.print(" ");
  82. Serial.println(sensor[l+1],BIN);
  83. }
  84. for(m=8;m<10;m+1)
  85. {
  86. Serial.print("voltage1:");
  87. Serial.print(sensor[m],BIN);
  88. Serial.print(" ");
  89. Serial.println(sensor[m+1],BIN);
  90. }
  91. for(n=10;n<12;n+1)
  92. {
  93. Serial.print("voltage2:");
  94. Serial.print(sensor[n],BIN);
  95. Serial.print(" ");
  96. Serial.println(sensor[n+1],BIN);
  97. }
  98. }
  99. void transmit(void)//傳至Mega2560
  100. {
  101. for(i=0;i<2;i+1)
  102. {
  103. Serial.write("current1:");
  104. Serial.write(sensor[i]);
  105. Serial.write(sensor[i+1]);
  106. Serial.write(10);
  107. }
  108. for(j=2;j<4;j+1)
  109. {
  110. Serial.write("current2:");
  111. Serial.write(sensor[j]);
  112. Serial.write(sensor[j+1]);
  113. Serial.write(10);
  114. }
  115. for(k=4;k<6;k+1)
  116. {
  117. Serial.write("temperature1:");
  118. Serial.write(sensor[k]);
  119. Serial.write(sensor[k+1]);
  120. Serial.write(10);
  121. }
  122. for(l=6;l<8;l+1)
  123. {
  124. Serial.write("temperature2:");
  125. Serial.write(sensor[l]);
  126. Serial.write(sensor[l+1]);
  127. Serial.write(10);
  128. }
  129. for(m=8;m<10;m+1)
  130. {
  131. Serial.write("voltage1:");
  132. Serial.write(sensor[m]);
  133. Serial.write(sensor[m+1]);
  134. Serial.write(10);
  135. }
  136. for(n=10;n<12;n+1)
  137. {
  138. Serial.write("voltage2:");
  139. Serial.write(sensor[n]);
  140. Serial.write(sensor[n+1]);
  141. Serial.write(10);
  142. }
  143. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
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)
                ~^~
stdout
Standard output is empty