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.

send-random.ino 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. * simulateur de telemesure automate
  3. */
  4. /* -------------------------------------------------- */
  5. #define NBVAL 4
  6. int values[NBVAL];
  7. /* -------------------------------------------------- */
  8. void setup() {
  9. int foo;
  10. Serial.begin(9600);
  11. pinMode(LED_BUILTIN, OUTPUT);
  12. for (foo=0; foo<NBVAL; foo++) {
  13. values[foo] = 0;
  14. }
  15. }
  16. /* -------------------------------------------------- */
  17. void updatevalues(void)
  18. {
  19. int foo;
  20. for (foo=0; foo<NBVAL; foo++) {
  21. if (rand()%100<33) {
  22. values[foo] += (foo + 1);
  23. }
  24. if (values[foo] > 1023) {
  25. values[foo] = rand()%25;
  26. }
  27. }
  28. }
  29. /* -------------------------------------------------- */
  30. void sendvalues(void)
  31. {
  32. int foo;
  33. Serial.print("X");
  34. for (foo=0; foo<NBVAL; foo++) {
  35. Serial.print(" ");
  36. Serial.print(values[foo]);
  37. }
  38. Serial.print("\n");
  39. }
  40. /* -------------------------------------------------- */
  41. void loop() {
  42. updatevalues();
  43. sendvalues();
  44. delay(800);
  45. }
  46. /* -------------------------------------------------- */