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,14 +26,24 @@ 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;
digitalWrite(LED_BUILTIN, HIGH);
for (foo=0; foo<NBVAL; foo++) { for (foo=0; foo<NBVAL; foo++) {
ptr[foo] = analogRead(adc_pins[foo]); ptr[foo] = 0;
delay(200); }
digitalWrite(LED_BUILTIN, HIGH);
for (pass=0; pass<NB_PASSE; pass++) {
for (foo=0; foo<NBVAL; foo++) {
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() {