======Communication série====== Il est parfois nécessaire de se connecter à un périphérique utilisant un mode de communication série. =====Protocole RS232===== [[wpfr>RS-232|Article sur Wikipédia]]. Sur une prise DE9, les broches utiles sont : ^ Broche ^ 2 ^ 3 ^ 5 | 4 | 8 | ^ Signal | RX | TX | GND | DTR | CTS | =====FTDI232===== {{ :outils:ftdi-usb-to-serial-converter-pinout-diagram.jpg?200|Cliquer pour agrandir}} Interface USB vers UART série * [[https://ftdichip.com/products/ft232rq/|Site officiel]] * [[https://www.amazon.fr/AZDelivery-Adaptateur-FT232RL-Arduino-Adapter/dp/B01N9RZK6I/ref=sr_1_3?__mk_fr_FR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=1G2Z9VII4RP10&keywords=ftdi232&sprefix=ftdi232%2Caps%2C112&sr=8-3&th=1|Le produit sur AMAZON]] * [[https://microcontrollerslab.com/ftdi-usb-to-serial-converter-cable-use-linux-windows/|Tutoriel pour mise en oeuvre]] =====PuTTY===== {{ :outils:putty_windows_configuration.png?200|}}Émulateur de terminal multi protocole. * [[https://www.chiark.greenend.org.uk/~sgtatham/putty/|Site officiel]] * [[https://portableapps.com/apps/internet/putty_portable|version portable]] * [[http://marc.terrier.free.fr/docputty.old/index.html|Manuel en français]] =====Mise en oeuvre===== - Connecter le FTDI232 au port USB et à la liaison série **(Attention : câble normal ou croisé)** - Lancer et configurer PuTTY ====Programme Arduino de test==== #define DELAY 3 // Delais ping en s long t = 0; // Compteur temps void setup() { // put your setup code here, to run once: Serial.begin(115200); Serial.println ("Début test"); } void loop() { // put your main code here, to run repeatedly: if (Serial.available() >= 1) { char x = Serial.read(); switch(x) { case 65: Serial.println("\nA : effacer"); break; // A case 66: Serial.println("\nB : retour"); break; // B default: Serial.write(x); } } if ((t * 1000 + 1000) < millis()) { t ++; if ((t % DELAY)) { Serial.println(); Serial.println(t); } } }