Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed LiquidCrystal_I2C_for_KL25Z
main.cpp@2:a98b2701814e, 2022-04-26 (annotated)
- Committer:
- micros22eq7
- Date:
- Tue Apr 26 05:19:09 2022 +0000
- Revision:
- 2:a98b2701814e
- Parent:
- 1:f9d42dc8c470
v5
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| micros22eq7 | 0:ab1f47ee482e | 1 | //CÓDIGO 1-B |
| micros22eq7 | 0:ab1f47ee482e | 2 | |
| micros22eq7 | 0:ab1f47ee482e | 3 | #include "mbed.h" |
| micros22eq7 | 0:ab1f47ee482e | 4 | #include "stdlib.h" |
| micros22eq7 | 0:ab1f47ee482e | 5 | #include <LiquidCrystal_I2C.h> |
| micros22eq7 | 0:ab1f47ee482e | 6 | #include <iostream> |
| micros22eq7 | 0:ab1f47ee482e | 7 | #include <string> |
| micros22eq7 | 0:ab1f47ee482e | 8 | |
| micros22eq7 | 0:ab1f47ee482e | 9 | Serial pc(USBTX, USBRX); // tx, rx |
| micros22eq7 | 0:ab1f47ee482e | 10 | |
| micros22eq7 | 0:ab1f47ee482e | 11 | //Los puertos SDA y SD8 están referenciados en el archivo LiquidCrystal_I2C.cpp |
| micros22eq7 | 0:ab1f47ee482e | 12 | // SDA -> PTC9 |
| micros22eq7 | 0:ab1f47ee482e | 13 | // SCL -> PTC8 |
| micros22eq7 | 0:ab1f47ee482e | 14 | // DIR TIPO |
| micros22eq7 | 0:ab1f47ee482e | 15 | LiquidCrystal_I2C lcd(0x4E, 16, 2); |
| micros22eq7 | 0:ab1f47ee482e | 16 | |
| micros22eq7 | 0:ab1f47ee482e | 17 | int main() |
| micros22eq7 | 0:ab1f47ee482e | 18 | { |
| micros22eq7 | 0:ab1f47ee482e | 19 | pc.printf("\x1b[2J"); //CLEAR |
| micros22eq7 | 0:ab1f47ee482e | 20 | pc.printf("\033[1;1H"); //Mueve cursor al origen |
| micros22eq7 | 0:ab1f47ee482e | 21 | |
| micros22eq7 | 0:ab1f47ee482e | 22 | int i, j; |
| micros22eq7 | 0:ab1f47ee482e | 23 | char datos[3][5]; // Matriz para almacenar datos |
| micros22eq7 | 0:ab1f47ee482e | 24 | |
| micros22eq7 | 0:ab1f47ee482e | 25 | // Inicia la LCD |
| micros22eq7 | 0:ab1f47ee482e | 26 | lcd.begin(); |
| micros22eq7 | 0:ab1f47ee482e | 27 | |
| micros22eq7 | 1:f9d42dc8c470 | 28 | lcd.print("Esperando ..."); |
| micros22eq7 | 0:ab1f47ee482e | 29 | pc.printf("\nIngresa 3 numeros decimales de la forma <X.X> SIN PRESIONAR ENTER\r\n"); |
| micros22eq7 | 0:ab1f47ee482e | 30 | |
| micros22eq7 | 0:ab1f47ee482e | 31 | for (i = 0; i < 3; i++) // Obtencion de datos desde terminal |
| micros22eq7 | 0:ab1f47ee482e | 32 | { |
| micros22eq7 | 0:ab1f47ee482e | 33 | pc.printf("\r\nDato %i: ", i + 1); |
| micros22eq7 | 0:ab1f47ee482e | 34 | for (j = 0; j < 3; j ++) |
| micros22eq7 | 0:ab1f47ee482e | 35 | datos[i][j] = pc.getc(); |
| micros22eq7 | 0:ab1f47ee482e | 36 | datos[i][3] = ' '; |
| micros22eq7 | 0:ab1f47ee482e | 37 | datos[i][4] = 0; |
| micros22eq7 | 0:ab1f47ee482e | 38 | pc.printf(" %s", datos[i]); |
| micros22eq7 | 0:ab1f47ee482e | 39 | } |
| micros22eq7 | 2:a98b2701814e | 40 | |
| micros22eq7 | 0:ab1f47ee482e | 41 | lcd.clear(); |
| micros22eq7 | 1:f9d42dc8c470 | 42 | lcd.print("Datos obtenidos: "); |
| micros22eq7 | 2:a98b2701814e | 43 | lcd.setCursor(2, 1); |
| micros22eq7 | 2:a98b2701814e | 44 | lcd.print(datos[0]); //Imprime datos obtenidos de terminal |
| micros22eq7 | 0:ab1f47ee482e | 45 | lcd.print(datos[1]); |
| micros22eq7 | 0:ab1f47ee482e | 46 | lcd.print(datos[2]); |
| micros22eq7 | 0:ab1f47ee482e | 47 | |
| micros22eq7 | 0:ab1f47ee482e | 48 | pc.printf("\n\r\nDatos enviados a la LCD..."); |
| micros22eq7 | 0:ab1f47ee482e | 49 | } |