ArduinoSTM32 Nucleo-F401RELab virtual

Nucleo-F401RE: knob on an LCD

An I2C LCD on D14/D15 shows the knob on A0 in volts; LD2 blinks by its STM32 name, PA5.

Nucleo-F401RE: knob on an LCD in Argynix Lab

The code

sketch.inoC++
// STM32 Nucleo-F401RE: an I2C LCD on D14 (SDA) and D15 (SCL) shows the knob on A0 in
// volts, read at 12 bits. LD2 is D13, which is also PA5: either name drives it.
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  Serial.begin(115200);
  pinMode(LED_BUILTIN, OUTPUT);
  analogReadResolution(12);
  lcd.init();
  lcd.backlight();
  lcd.print("Nucleo-F401RE");
}

void loop() {
  int raw = analogRead(A0);  // 0..4095
  float volts = raw * 3.3f / 4095.0f;
  lcd.setCursor(0, 1);
  lcd.print("A0 ");
  lcd.print(volts, 2);
  lcd.print(" V   ");
  digitalWrite(PA5, (millis() / 500) % 2);
  Serial.println(volts, 2);
  delay(100);
}