#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
int irpin=PA0;
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() {
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() / 1000); //Print the value of secounds
lcd.clear(); //clears lcd
//declare varible angle as int
int reading;
int distance; //declare varible reading as int
reading = analogRead(irpin); //read analog value from pin PA3
distance=reading*0.065; //it puts angle value at servo
lcd.setCursor(0,0); //setting cursor at first row and first column
lcd.print("distance:"); //puts Angle in LCD
lcd.print(distance); //puts value at angle
delay(100);
}