Browse Source

now reading all 4 tempecaptors

tth 1 year ago
parent
commit
b6d49bd6f8
1 changed files with 18 additions and 10 deletions
  1. 18
    10
      simulator/rdtemp/rdtemp.ino

+ 18
- 10
simulator/rdtemp/rdtemp.ino View File

@@ -6,8 +6,6 @@
6 6
 #define NBVAL   4
7 7
 #define DELAI   12000
8 8
 
9
-int   values[NBVAL];
10
-
11 9
 /* -------------------------------------------------- */
12 10
 void setup() {
13 11
   Serial.begin(9600);
@@ -21,33 +19,43 @@ void setup() {
21 19
   analogReference(INTERNAL1V1); // Pour Arduino Mega2560
22 20
   
23 21
   delay(1000);
22
+  Serial.print("M running\n");
24 23
 }
25 24
 /* -------------------------------------------------- */
26
-void updatevalues(void)
25
+/* ================================================== */
26
+short adc_pins[] = { A0, A1, A2, A4 };
27
+/* -------------------------------------------------- */
28
+void updatevalues(short *ptr)
27 29
 {
28 30
   int foo;
29 31
   for (foo=0; foo<NBVAL; foo++) {
30
-    values[foo] = analogRead(A0);
31
-    delay(200);
32
+    ptr[foo] = analogRead(adc_pins[foo]);
33
+   delay(200);
32 34
    }
33 35
 }
34 36
 /* -------------------------------------------------- */
35
-void sendvalues(void)
37
+void sendvalues(short *ptr)
36 38
 {
37 39
   int foo;
38 40
 
39 41
   Serial.print("T");
40 42
   for (foo=0; foo<NBVAL; foo++) {
41 43
     Serial.print(" ");
42
-    Serial.print(values[foo]);
44
+    Serial.print(ptr[foo]);
43 45
     }
44 46
   Serial.print("\n");
45 47
 }
46 48
 /* -------------------------------------------------- */
47
-
49
+void update_and_send(void)
50
+{
51
+  short values[NBVAL];
52
+  
53
+  updatevalues(values);
54
+  sendvalues(values);
55
+}
56
+/* ================================================== */
48 57
 void loop() {
49
-  updatevalues();
50
-  sendvalues();
58
+  update_and_send();
51 59
   delay(DELAI);
52 60
 }
53 61
 

Loading…
Cancel
Save