Introduction: Animation on 16x2 I2c LCD USING STM32 Nucleo
Hi friends,this is a tutorial illustrating how to make a custom animation on a 16x2 i2c LCD .There are very few things needed for the project,so if you have access to the code you can finish it in 1 hour.
After following this tutorial you will be able to design your own custom animation on microcontroller.
ELECTRONICS NEEDED FOR PROJECT:-
1)STM32L476RG Nucelo Board
2)16x2 i2c LCD
SOFTWARE NEEDED :-
Connections:Connect PB6 to I2C-SCK and I2C-SDA to PB7 pin of nucleo board.
Step 1: Open STM32Cubemx and Make Settings Corresponding to Images Attached.
1)After selecting STM32L476RG as microcontroller in STM32CUBE select I2C1 interface as i2c.
2)Set clock value to a maximum value (80Mhz)
3)After that select Timer1 and Timer2 and later initialize its values as given in later part of tutorial.
4)Select Timer1 update interrupt and Timer2 global interrupt in NVIC settings.
5)Generate code for the Project in Keil 5.
Step 2: Make Necessary Custom Images and Add Its Codes in Custom_char.h File.
1)Each position in a 16x2 lcd can be divided into 32 segments ,each segment consists of 5x8 pixels.
2)You can visualize the image and its boundary on the segment and represent each part of segment with value 1 if the position on segment is part of the image otherwise assign it as a value 0 which gives values for each of row as shown in attached picture.
3)Put that value from step2 in custom_char.h file given in the code attached.
Step 3: Adding Relevant Code in Keil 5
1)Write command to start Timer1 and Timer2 in main.c file.Timer 1 is used to clear the LCD and Timer2 is used for displaying the images.
2)Write values for Prescalar and Autoreload values for Timer1 and Timer2 in main.c file which is same for both timers.
3)Add relevant code in Timer1 interrupt routine and for Timer2 interrupt routine in stm32l4_it.c file.