This code initializes the I2C interface and sends initialization commands to the JHD-2x16-I2C display. It then prints the string "Hello, World!" to the display.
#define I2C_ADDRESS 0x27
// Initialize LCD uint8_t init_sequence[] = 0x33, // Function set: 8-bit interface, 2 lines, 5x8 dots 0x32, // Function set: 4-bit interface, 2 lines, 5x8 dots 0x28, // Function set: 4-bit interface, 2 lines, 5x8 dots 0x0C, // Display control: Display on, cursor off, blink off 0x01 // Clear display ; for (uint8_t i = 0; i < sizeof(init_sequence); i++) 0; // Write address TWCR = (1 << TWINT) jhd-2x16-i2c proteus
void lcd_print(char *str) // Send I2C data TWDR = (I2C_ADDRESS << 1) This code initializes the I2C interface and sends
#include <stdint.h> #include <stdbool.h> #include <avr/io.h> #include <avr/interrupt.h> // Function set: 8-bit interface
void lcd_init() // Initialize I2C TWBR = 0x18; // 100 kHz TWSR = 0x00;