LCD4 Hello World example (L152)

Name of the project

l152_lcd4_hello

Description

The project will display text and numbers on a 2×16 alphanumeric LCD.

Code snippet (initial code, project structure and VSCode files generated by VPC)

uint8_t s[6];
const uint8_t sr[] = "Hello World!";
  
int main(void){
  /* local variables */
  uint8_t i = 0;
  uint8_t counter = 0;
  
  /* mandatory system initializations */
  vpc_system_init();
  //vpc_rtc_init(); /* enable if required */  
  vpc_gpio_init();
  //vpc_usart2_uart_init(); /* enable if required */ 
  /* third-party initializations */
  lcd_init(LCD_HD44780);
  
  /* do your own initializations below */
  my_delay_ms(1000);
  lcd_cursor_position(0, 0);
  lcd_write_strF(sr);
  
  while(1){
    /* your forever repeating code */
    counter+=1;
    lcd_cursor_position(1, 0);
    byte2dec(counter, s);
    for(i = 0; i < 3; i++)
      lcd_write_char(s[i]);
    my_delay_ms(500);
    GPIO_ToggleBits(LD2_GPIO_Port, LD2_Pin);
  }
  return 0;
}

Project published in repository.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.