2018-12-20 11:57:23 +01:00
|
|
|
/*
|
|
|
|
* simulateur de telemesure automate
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|
|
|
|
#define NBVAL 4
|
|
|
|
|
|
|
|
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()%15;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|
|
|
|
void sendvalues(void)
|
|
|
|
{
|
|
|
|
int foo;
|
|
|
|
|
2018-12-29 09:49:07 +01:00
|
|
|
Serial.print("X");
|
2018-12-20 11:57:23 +01:00
|
|
|
for (foo=0; foo<NBVAL; foo++) {
|
|
|
|
Serial.print(" ");
|
|
|
|
Serial.print(values[foo]);
|
|
|
|
}
|
|
|
|
Serial.print("\n");
|
|
|
|
}
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|
|
|
|
void loop() {
|
|
|
|
updatevalues();
|
|
|
|
sendvalues();
|
2018-12-29 09:49:07 +01:00
|
|
|
delay(2500);
|
2018-12-20 11:57:23 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* -------------------------------------------------- */
|
|
|
|
|