Last active
December 11, 2019 13:57
L'Arduino émet par communication série les mesures d'un capteur (un potentiomètre branché à l'entrée A0).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
L'Arduino émet par communication série | |
les mesures d'un capteur (un potentiomètre | |
branché à l'entrée A0). | |
Plus d'infos: | |
https://electroniqueamateur.blogspot.com/2019/12/graphique-en-temps-reel-des-mesures.html | |
*/ | |
unsigned long tempsDebut; | |
void setup() { | |
Serial.begin(115200); | |
} | |
void loop() { | |
int messageRecu = 0; | |
unsigned long valeurx; | |
int valeury; | |
if (Serial.available() > 0) { | |
messageRecu = Serial.read(); | |
if (messageRecu == 'i') { // commande d'initialisation | |
tempsDebut = millis(); // remise à zéro du chronomètre | |
} | |
if (messageRecu == 'e') { // commande d'envoi de données | |
valeurx = millis() - tempsDebut; | |
valeury = analogRead(A0); | |
Serial.println(String(valeurx)+' '+String(valeury)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment