now reading all 4 tempecaptors

This commit is contained in:
Tonton Th 2019-02-22 17:16:01 +01:00
parent faca30264b
commit b6d49bd6f8

View File

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