10/26

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;}

你可能感兴趣的:(10/26)