now reading all 4 tempecaptors

This commit is contained in:
tth 2019-02-22 17:16:01 +01:00
parent faca30264b
commit b6d49bd6f8
1 changed files with 18 additions and 10 deletions

View File

@ -6,8 +6,6 @@
#define NBVAL 4 #define NBVAL 4
#define DELAI 12000 #define DELAI 12000
int values[NBVAL];
/* -------------------------------------------------- */ /* -------------------------------------------------- */
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
@ -21,33 +19,43 @@ void setup() {
analogReference(INTERNAL1V1); // Pour Arduino Mega2560 analogReference(INTERNAL1V1); // Pour Arduino Mega2560
delay(1000); delay(1000);
Serial.print("M running\n");
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
void updatevalues(void) /* ================================================== */
short adc_pins[] = { A0, A1, A2, A4 };
/* -------------------------------------------------- */
void updatevalues(short *ptr)
{ {
int foo; int foo;
for (foo=0; foo<NBVAL; foo++) { for (foo=0; foo<NBVAL; foo++) {
values[foo] = analogRead(A0); ptr[foo] = analogRead(adc_pins[foo]);
delay(200); delay(200);
} }
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
void sendvalues(void) void sendvalues(short *ptr)
{ {
int foo; int foo;
Serial.print("T"); Serial.print("T");
for (foo=0; foo<NBVAL; foo++) { for (foo=0; foo<NBVAL; foo++) {
Serial.print(" "); Serial.print(" ");
Serial.print(values[foo]); Serial.print(ptr[foo]);
} }
Serial.print("\n"); Serial.print("\n");
} }
/* -------------------------------------------------- */ /* -------------------------------------------------- */
void update_and_send(void)
{
short values[NBVAL];
updatevalues(values);
sendvalues(values);
}
/* ================================================== */
void loop() { void loop() {
updatevalues(); update_and_send();
sendvalues();
delay(DELAI); delay(DELAI);
} }