You'll need to set up the GPIO pins for I2C communication, configure the I2C timing parameters, and enable the I2C peripheral. Initialize the I2C peripheral in the STM HAL API code. You can find these libraries in the STM32Cube package, which is available for download from the STMicroelectronics website. Import the required STM HAL libraries for I2C communication.In the setup, the LCD is initiated with lcd.init() and the backlight is turned on with lcd.backlight().Converting an I2C wire library based Arduino code to STM HAL API based code involves a few steps. Connect to LCD via I2C, default address 0x27 (A0-A2 not jumpered) You will need to change ‘lcd’ to the new name in the rest of the sketch. You can give it a different name if you want like ‘menu_display’. Note that we have called the display ‘lcd’. When using a 20×4 LCD, change this line to LiquidCrystal_I2C(0x27,20,4) This is where you will need to change the default address to the address you found earlier if it happens to be different. The next step is to create an LCD object with the LiquidCrystal_I2C class and specify the address and dimensions.įor this, we use the function LiquidCrystal_I2C(address, columns, rows). #include // Library for I2C communication The other library imports wire.h automatically. *When using the latest version of the LiquidCrystal_I2C library it is no longer needed to include the wire.h library in your sketch. In the rest of this tutorial, I will cover more of the built-in functions of this library. As mentioned earlier we need both the wire.h* and the LiquidCrystal_I2C library. First, the required libraries are included.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |