次のコードを使用すると、次のようなログが得られます。何故ですか?
int analogPin = 5;
int val = 0;
void setup(void) {
Serial.begin(9600);
}
void loop(void) {
val = analogRead(analogPin);
Serial.print("Analog reading = ");
Serial.println(val);
}
結果:
Analog reading = 998
Analog reading = 981
Analog reading = 511
Analog reading = 159
Analog reading = 24
Analog reading = 108
Analog reading = 439
Analog reading = 946
Analog reading = 1023
Analog reading = 420
Analog reading = 116
Analog reading = 25
Analog reading = 151
Analog reading = 542
Analog reading = 997
Analog reading = 982
Analog reading = 513
Analog reading = 161
Analog reading = 25
Analog reading = 107
Analog reading = 437
Analog reading = 945
Analog reading = 1023
Analog reading = 421
Analog reading = 117
Analog reading = 25
Analog reading = 150
Analog reading = 541
Analog reading = 997
Analog reading = 983
Analog reading = 515
Analog reading = 162
Analog reading = 25
Analog reading = 107
Analog reading = 437
Analog reading = 945
Analog reading = 1023
Analog reading = 422
Analog reading = 117
Analog reading = 25
Analog reading = 149
Analog reading = 540
Analog reading = 997
Analog reading = 983
Analog reading = 516
Analog reading = 162
Analog reading = 25
Analog reading = 107
Analog reading = 436
Analog reading = 945
Analog reading = 1023
Analog reading = 422
Analog reading = 117
Analog reading = 25
Analog reading = 150
Analog reading = 540
Analog reading = 998
Analog reading = 982
Analog reading = 516
Analog reading = 162
Analog reading = 25
Analog reading = 108
Analog reading = 437
結果は単なるノイズですか?
そして、ケーブルを差し込むとすぐに、次のパターンが表示されます。
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 72
Analog reading = 447
Analog reading = 1023
Analog reading = 1023
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 118
Analog reading = 849
Analog reading = 1023
Analog reading = 835
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 40
Analog reading = 401
Analog reading = 1023
Analog reading = 1023
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 0
Analog reading = 89
Analog reading = 475
Analog reading = 1023
Analog reading = 1023
それは私のハートビートかそこらですか?空のピンに何がそのような影響を与えることができるのか分かりません。