Nuestro Itinerario de aprendizaje maker esta desarrollado para aprender todos los fundamentos y un poco más acerca de electrónica y programación.
Si completas el itinerario serás capaz de crear casi cualquier proyecto que imagines. En cada proyecto se introducen nuevos conceptos, de modo que aprenderás haciendo o creando de una manera amena y divertida.
Descubre la manera de incorporar una pantalla LCD en tus creaciones, de modo que ¡podrás enviar mensajes desde tu programa al mundo exterior!
Learn to show messages in a LCD display
• DIFFICULTY LEVEL: Intermediate
• DURATION OF THE ACTIVITY: 45 min.
1 - Build&Code 4in1 board
1 - 16X2 LCD Display with l2C
1 - Switch Button
1 - Any analog sensor
Battery holder, USB cable and wires.
The LCD display with l2Clet us show messages to users. There are different types of LCD, and sizes. We use a monochromatic one with 2 lines or rows and 16 characters per line (2x16)
Seems difficult to control it? well, this LCD display has an I2C transceiver. I2C is a serial protocol for two-wire interface to connect low-speed devices. 4in1 board has a serial port also, where we can connect to many devices in a serial bus. Each device has an address, so we can send or read values. We will use it to send characters and they ubication in LCD display.
Universal Serial Bus ( USB) vs I2C
USB devices are very similar in concept, they also communicate data by serial line (one byte rear another one) and can be connected many devices simultaniously (bus). I2C has slower speed, and has different specifications, but both require only two wires to transmit data, and two more for power.
We use serial port of the Build&Code 4in1 board, using Analog ports. Pay attention to the diagram:
Connect wires from 4in1 board to components:
- A5 S pin (blue) to SCL pin from LCD display
- A4 S pin (blue) to SDA pin from LCD display
- A4 V pin (red) to VCC pin from LCD display
- A4 G pin (black) to GND pin from LCD display
- DIO4 to button
- A2 to Analog sensor (LDR, potentiometer)
To be ready to program easily the display, is required to install library LiquidCrystal_I2C in Arduino IDE, and LCD i2c by vn_nda iIn mBlock 5. Find in this page how to add libraries! With this exercise you will see how to put your name in the LCD Display. See the code!!
#include <Wire.h> #include <LiquidCrystal_I2C.h> // LIBRERIA NECESARIA PARA LA PANTALLA LCD LiquidCrystal_I2C lcd(0x27, 16, 2); // CONFIGURACIÓN DE LA PANTALLA LCD void setup() { lcd.begin(); // INICIALIZACION PANTALLA LCD lcd.clear(); // LIMPIAR LA PANTALLA LCD } void loop() { // ESCRIBIR EN LA PANTALLA LCD lcd.setCursor(0, 0); // ESCRIBIR EN LA COLUMNA 0 LINEA 1 lcd.print("INSERTAR NOMBRE"); // MOSTRAR POR PANTALLA EL NOMBRE }
Read the analog sensor value and send it to LCD display. Yeah! You can do it with your eyes shut!
#include <Wire.h> #include <LiquidCrystal_I2C.h> // LIBRERIA PARA LA PANTALLA LCD LiquidCrystal_I2C lcd(0x27, 16, 2); // CONFIGURACIÓN DE LA PANTALLA LCD void setup() { // lIMPIAR PANTALLA LCD lcd.begin(); // INICIALIZACION PANTALLA LCD lcd.clear(); // LIMPIAR LA PANTALLA LCD } void loop() { // ESCRIBIR EN LA PANTALLA LCD int sensor= analogRead(A2); lcd.setCursor(0, 0); // ESCRIBIR EN LA COLUMNA 0 LINEA 1 lcd.print(sensor); // MOSTRAR POR PANTALLA LOS VALORES DEL SENSOR }
Using Arduino IDE, we can input text from our computer throught serial port (USB) and then our program will send it to the LCD display. Let's see how to do it!!
// WRITE ON THE KEYBOARD AND LEAVE ON THE LCD SCREEN #include <Wire.h> // This library allows you to communicate with I2C / TWI devices #include <LiquidCrystal_I2C.h> //LCD I2C Library int pinbutton = 4, button; //VARIABLE AND BUTTON CONECTOR char input; // Input variable from computer keyboard LiquidCrystal_I2C lcd(0x27, 16, 2); // LCD parameters void setup(){ pinMode (pinbutton, INPUT); // Declare button as an input lcd.begin(); lcd.backlight(); // turn on the LCD backlight lcd.clear(); // Delete content from the LCD screen Serial.begin(9600); // serial port speed } void loop(){ lcd.blink(); if (Serial.available()>0) // Serial port reading { input=Serial.read(); // Save information of the serial port in the input variable lcd.print(input); // display the input variable on the LCD screen } button = digitalRead ( pinbutton); // PRESS THE BUTTON AND CLEAR THE LCD SCREEN if (button == HIGH) { lcd.clear(); } }
An LCD Display always is a good component to show information to user. We propose you to do a billboard so you can know all films disponible to see today. Here cardboard template
#include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x27, 16, 2); void setup(){ /* LiquidCrystal_I2C() – Constructor de la clase, configura el hardware. init() – Prepara el LCD para su uso. clear() – Borra todos los caracteres de la pantalla LCD. setCursor(col, row) – Permite mover el cursor a la posición indicada en sus parámetros. print() – Imprime una variable o literal en la pantalla scrollDisplayLeft() y scrollDisplayRight() – Recorre el contenido de la pantalla a la izquierda o a la derecha backlight() y noBacklight() – Métodos para encender / apagar la iluminación de fondo createChar(num, data) – Crear un carácter definido por el usuario en la memoria del controlador de pantalla */ lcd.begin(); lcd.clear(); lcd.setCursor(0,1); lcd.print("ebotics"); } void loop(){ lcd.setCursor(0,0); lcd.print("Project7-LCD Billboard"); lcd.scrollDisplayLeft(); delay (300); }
El Mega Maker Kit te ofrece el todo el material que necesitas para completar el itinerario, pero si dispones de otro kit, también puedes realizar algunos proyectos. Te animamos a que los revises todos, o que compres los componentes que necesites. Puedes verificar que actividades puedes realizar en nuestra página del Itinerario de aprendizaje.