Fernando Morales / Mbed 2 deprecated I2C_1_B

Dependencies:   mbed

Revision:
2:b2512ade96de
Parent:
1:b2c40f461dbd
Child:
3:59d6245cad22
--- a/main.cpp	Mon Apr 25 02:20:54 2022 +0000
+++ b/main.cpp	Mon Apr 25 05:47:44 2022 +0000
@@ -1,25 +1,47 @@
-#include "mbed.h"
-#include <LiquidCrystal_I2C.h>
-
-// Set the LCD address to 0x27 for a 16 chars and 2 line display
-LiquidCrystal_I2C lcd(0x4E, 16, 2);
+//CÓDIGO 1-B
 
 
+#include "mbed.h"
+#include "stdlib.h"
+#include <LiquidCrystal_I2C.h>
+#include <iostream>
+#include <string>
+
+Serial pc(USBTX, USBRX); // tx, rx
+
+//Los puertos SDA  y SD8 están referenciados en el archivo LiquidCrystal_I2C.cpp
+// SDA -> PTC9
+// SCL -> PTC8
+//                     DIR   TIPO
+LiquidCrystal_I2C lcd(0x4E, 16, 2);
 
 int main()
 {
- 
-    // initialize the LCD
+    pc.printf("\x1b[2J");       //CLEAR
+    pc.printf("\033[1;1H");     //Mueve cursor al origen
+    
+    int i, j;
+    char datos[3][5];
+    
+    // Inicia the LCD
     lcd.begin();
 
-    // Turn on the blacklight and print a message.
+    // Turn on the blacklight.
     lcd.backlight();
-    lcd.print("Hello, world!");
     
-    while (1) 
+    lcd.print("Esperando ...");
+    pc.printf("\nIngresa 3 datos de 4 caracteres al programa por medio de la terminal: ");
+    for (i = 0; i < 3; i++)
     {
-       
+        pc.printf("\r\nDato %i: ", i + 1);
+        for (j = 0; j < 3; j ++)
+            datos[i][j] = pc.getc();
+        datos[i][3] = ' ';
+        datos[i][4] = 0;
     }
- 
+    lcd.clear();
+    lcd.print(datos[0]);
+    lcd.print(datos[1]);
+    lcd.print(datos[2]);
 }