Last active
August 9, 2021 13:33
-
-
Save aldrinmartoq/813f75c865a04dd2733dafd0e64a7ea6 to your computer and use it in GitHub Desktop.
LCD en Arduino UNO con módulo I2C (4 patitas)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
0. Probar conexión | |
Módulo I2C para LCD -> Arduino | |
- GND -> GND | |
- VCC -> 5V | |
- SDA -> A4 | |
- SCL -> A5 | |
Fuente original https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24 | |
*/ | |
#include <Wire.h> | |
void i2c_setup() { | |
Wire.begin(); | |
Serial.begin(9600); | |
Serial.println("\nI2C Scanner"); | |
} | |
void i2c_loop() { | |
byte error, address; | |
int devices; | |
Serial.println("Buscando..."); | |
devices = 0; | |
for (address = 1; address < 127; address++) { | |
Wire.beginTransmission(address); | |
error = Wire.endTransmission(); | |
if (error == 0) { | |
Serial.print("I2C encontrado en 0x"); | |
if (address < 16) Serial.print("0"); | |
Serial.print(address, HEX); | |
Serial.println(":-D"); | |
devices++; | |
} else if (error == 4) { | |
Serial.print("Error desconocido en 0x"); | |
if (address < 16) Serial.print("0"); | |
Serial.print(address, HEX); | |
Serial.println(":-("); | |
} | |
} | |
Serial.print(devices); | |
Serial.println(" dispositivos encontrados.\n\n"); | |
delay(5000); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Probar LCD: | |
- Instalar "liquidcrystal i2c" desde Library Manager en IDE | |
Fuente original https://create.arduino.cc/projecthub/akshayjoseph666/interface-i2c-16x2-lcd-with-arduino-uno-just-4-wires-273b24 | |
*/ | |
#include <Wire.h> | |
#include <LiquidCrystal_I2C.h> | |
LiquidCrystal_I2C lcd(0x27, 16, 2); | |
void setup() { | |
lcd.init(); | |
lcd.backlight(); | |
} | |
void loop() { | |
lcd.clear(); | |
lcd.setCursor(2, 0); | |
lcd.print("Hola"); | |
Serial.println("Hola"); | |
delay(500); | |
lcd.clear(); | |
lcd.setCursor(7, 1); | |
lcd.print("tierra!"); | |
Serial.println("tierra!"); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment