Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. char Carac; // Initialisation d'une variable char
  2.  
  3. void setup() {
  4.  
  5. pinMode(13, OUTPUT); // initialisation de la LED 13 en sortie
  6. Serial.begin(9600); // init Serial à 9600baud, c’est la liaison encapsulée dans USB
  7. }
  8. void loop() {
  9.  
  10. if (Serial.available() > 0) { // Vérification si quelque chose est envoyer sur le moniteur série
  11.  
  12. Carac = Serial.read(); // Lecture du caractère présent sur le moniteur série
  13.  
  14.  
  15. Serial.print("Caractère reçu: ");
  16. Serial.println(Carac); // Affiche du caractère dans le moniteur série
  17.  
  18. if (Carac == 'M') // Si le caractère reçu est M
  19. {
  20.  
  21. Serial.println("M recu, led allume");
  22. digitalWrite(13, HIGH); // Allumer la LED 13
  23. }
  24.  
  25. else if( Carac=='A') // Si le caractère reçu est A
  26. {
  27.  
  28. Serial.println("A recu, led eteinte");
  29. digitalWrite(13, LOW); // Eteindre le LED 13
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement