10/26

2017-10-30  本文已影响0人  王子龙同学

smooth输入(10个值平均值,新值与前9个值)

int readings[numReadings];

void loop() {

total= total - readings[readIndex];

readings[readIndex] = analogRead(inputPin);

total= total + readings[readIndex];

readIndex = readIndex + 1;

if (readIndex >= numReadings)

readIndex = 0;

average = total / numReadings;}

上一篇 下一篇

猜你喜欢

热点阅读