2019-01-13 02:26:15 +11:00
|
|
|
/*
|
|
|
|
* lecture des capteurs de temperature LM35
|
|
|
|
*/
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|
|
|
|
#define NBVAL 4
|
2019-02-07 20:18:10 +11:00
|
|
|
#define DELAI 12000
|
2019-01-13 02:26:15 +11:00
|
|
|
|
|
|
|
int values[NBVAL];
|
|
|
|
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
void setup() {
|
|
|
|
Serial.begin(9600);
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT);
|
2019-01-28 00:59:26 +11:00
|
|
|
Serial.print("\n");
|
2019-02-07 20:18:10 +11:00
|
|
|
/* XXX */
|
|
|
|
/* changing the voltage reference of the ADC
|
|
|
|
* greatly increase the prcision on the limited
|
|
|
|
* range of our temperatures.
|
|
|
|
*/
|
|
|
|
analogReference(INTERNAL1V1); // Pour Arduino Mega2560
|
|
|
|
|
|
|
|
delay(1000);
|
2019-01-13 02:26:15 +11:00
|
|
|
}
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
void updatevalues(void)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
for (foo=0; foo<NBVAL; foo++) {
|
|
|
|
values[foo] = analogRead(A0);
|
2019-02-07 20:18:10 +11:00
|
|
|
delay(200);
|
2019-01-13 02:26:15 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
void sendvalues(void)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
|
|
|
Serial.print("T");
|
|
|
|
for (foo=0; foo<NBVAL; foo++) {
|
|
|
|
Serial.print(" ");
|
|
|
|
Serial.print(values[foo]);
|
|
|
|
}
|
|
|
|
Serial.print("\n");
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
updatevalues();
|
|
|
|
sendvalues();
|
|
|
|
delay(DELAI);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|