#include <LiquidCrystal.h> // include the LCD library
const int rs = PB11, en = PB10, d4 = PA4, d5 = PA3, d6 = PA2, d7 = PA1; //STM32 Pins to which LCD is connected
LiquidCrystal lcd(rs, en, d4, d5, d6, d7); //Initialize the LCD
void setup() {
lcd.begin(16, 2);//Defining 16*2 LCD
lcd.setCursor(0, 0); //LCD Row 0 and Column 0
lcd.print("Interfacing LCD"); //Print this Line
lcd.setCursor(0, 1); //LCD Row 0 and Column 1
lcd.print("with STM32 Board"); //Print this Line
delay(4000); //wait for four secounds
lcd.clear(); //Clear the screen
}
void loop() {
int irpin=PA15;
lcd.setCursor(0, 0); //LCD Row 0 and Column 0
lcd.print(" STM32 with LCD "); //Print This Line
lcd.setCursor(0, 1); //LCD Row 0 and Column 1
lcd.print(millis() / 100); //Print the value of seconds
lcd.clear();
int reading;
int distance;
reading=analogRead(irpin);
distance=reading*0.065;
lcd.setCursor(0,0);
lcd.print("distance:");
lcd.print(distance);
delay(1000);
}