Browse Source

taking four sample by pass

phyto 1 year ago
parent
commit
953650c953
1 changed files with 16 additions and 5 deletions
  1. 16
    5
      simulator/rdtemp/rdtemp.ino

+ 16
- 5
simulator/rdtemp/rdtemp.ino View File

@@ -4,7 +4,7 @@
4 4
 /* -------------------------------------------------- */
5 5
 
6 6
 #define NBVAL   4
7
-#define DELAI   5000
7
+#define DELAI   10000
8 8
 
9 9
 /* -------------------------------------------------- */
10 10
 void setup() {
@@ -26,15 +26,25 @@ void setup() {
26 26
 /* -------------------------------------------------- */
27 27
 /* ================================================== */
28 28
 short adc_pins[] = { A0, A1, A2, A4 };
29
+#define NB_PASSE  4
29 30
 /* -------------------------------------------------- */
30 31
 void updatevalues(short *ptr)
31 32
 {
32
-  int foo;
33
+  short foo, pass;
34
+
35
+  for (foo=0; foo<NBVAL; foo++) { 
36
+    ptr[foo] = 0;
37
+    }   
33 38
   digitalWrite(LED_BUILTIN, HIGH);
34
-  for (foo=0; foo<NBVAL; foo++) {
35
-    ptr[foo] = analogRead(adc_pins[foo]);
36
-    delay(200);
39
+  for (pass=0; pass<NB_PASSE; pass++) {
40
+    for (foo=0; foo<NBVAL; foo++) {
41
+      ptr[foo] += analogRead(adc_pins[foo]);
42
+      delay(100);
43
+      }
37 44
     }
45
+  for (foo=0; foo<NBVAL; foo++) { 
46
+    ptr[foo] /= NB_PASSE;
47
+    }   
38 48
   digitalWrite(LED_BUILTIN, LOW);
39 49
 }
40 50
 /* -------------------------------------------------- */
@@ -56,6 +66,7 @@ void update_and_send(void)
56 66
   
57 67
   updatevalues(values);
58 68
   sendvalues(values);
69
+  
59 70
 }
60 71
 /* ================================================== */
61 72
 void loop() {

Loading…
Cancel
Save