Monitoring du Phytotron
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rdtemp.ino 1.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * lecture des capteurs de temperature LM35
  3. */
  4. /* -------------------------------------------------- */
  5. #define NBVAL 4
  6. #define DELAI 12000
  7. int values[NBVAL];
  8. /* -------------------------------------------------- */
  9. void setup() {
  10. Serial.begin(9600);
  11. pinMode(LED_BUILTIN, OUTPUT);
  12. Serial.print("\n");
  13. /* XXX */
  14. /* changing the voltage reference of the ADC
  15. * greatly increase the prcision on the limited
  16. * range of our temperatures.
  17. */
  18. analogReference(INTERNAL1V1); // Pour Arduino Mega2560
  19. delay(1000);
  20. }
  21. /* -------------------------------------------------- */
  22. void updatevalues(void)
  23. {
  24. int foo;
  25. for (foo=0; foo<NBVAL; foo++) {
  26. values[foo] = analogRead(A0);
  27. delay(200);
  28. }
  29. }
  30. /* -------------------------------------------------- */
  31. void sendvalues(void)
  32. {
  33. int foo;
  34. Serial.print("T");
  35. for (foo=0; foo<NBVAL; foo++) {
  36. Serial.print(" ");
  37. Serial.print(values[foo]);
  38. }
  39. Serial.print("\n");
  40. }
  41. /* -------------------------------------------------- */
  42. void loop() {
  43. updatevalues();
  44. sendvalues();
  45. delay(DELAI);
  46. }
  47. /* -------------------------------------------------- */