taking four sample by pass

This commit is contained in:
phyto 2019-04-03 18:38:32 +02:00
parent c9e78aa11a
commit 953650c953

View File

@ -4,7 +4,7 @@
/* -------------------------------------------------- */ /* -------------------------------------------------- */
#define NBVAL 4 #define NBVAL 4
#define DELAI 5000 #define DELAI 10000
/* -------------------------------------------------- */ /* -------------------------------------------------- */
void setup() { void setup() {
@ -26,15 +26,25 @@ void setup() {
/* -------------------------------------------------- */ /* -------------------------------------------------- */
/* ================================================== */ /* ================================================== */
short adc_pins[] = { A0, A1, A2, A4 }; short adc_pins[] = { A0, A1, A2, A4 };
#define NB_PASSE 4
/* -------------------------------------------------- */ /* -------------------------------------------------- */
void updatevalues(short *ptr) void updatevalues(short *ptr)
{ {
int foo; short foo, pass;
for (foo=0; foo<NBVAL; foo++) {
ptr[foo] = 0;
}
digitalWrite(LED_BUILTIN, HIGH); digitalWrite(LED_BUILTIN, HIGH);
for (foo=0; foo<NBVAL; foo++) { for (pass=0; pass<NB_PASSE; pass++) {
ptr[foo] = analogRead(adc_pins[foo]); for (foo=0; foo<NBVAL; foo++) {
delay(200); ptr[foo] += analogRead(adc_pins[foo]);
delay(100);
}
} }
for (foo=0; foo<NBVAL; foo++) {
ptr[foo] /= NB_PASSE;
}
digitalWrite(LED_BUILTIN, LOW); digitalWrite(LED_BUILTIN, LOW);
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
@ -56,6 +66,7 @@ void update_and_send(void)
updatevalues(values); updatevalues(values);
sendvalues(values); sendvalues(values);
} }
/* ================================================== */ /* ================================================== */
void loop() { void loop() {