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.
 
 
 
 
 

56 lines
1.0 KiB

/*
* simulateur de telemesure automate
*/
/* -------------------------------------------------- */
#define NBVAL 4
#define DELAI 1664
int values[NBVAL];
/* -------------------------------------------------- */
void setup() {
int foo;
Serial.begin(9600);
pinMode(LED_BUILTIN, OUTPUT);
for (foo=0; foo<NBVAL; foo++) {
values[foo] = 0;
}
}
/* -------------------------------------------------- */
void updatevalues(void)
{
int foo;
for (foo=0; foo<NBVAL; foo++) {
if (rand()%100<33) {
values[foo] += (foo + 1);
}
if (values[foo] > 1023) {
values[foo] = rand()%25;
}
}
}
/* -------------------------------------------------- */
void sendvalues(void)
{
int foo;
Serial.print("X");
for (foo=0; foo<NBVAL; foo++) {
Serial.print(" ");
Serial.print(values[foo]);
}
Serial.print("\n");
}
/* -------------------------------------------------- */
void loop() {
updatevalues();
sendvalues();
delay(DELAI);
}
/* -------------------------------------------------- */