Built-in project · STM32 Nucleo-F411RE

Nucleo analog read

A potentiometer on A0 of an STM32 Nucleo-F411RE, read in ten bits and printed with its voltage. The whole build, an STM32 Nucleo-F411RE and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner Runs in your browser. Free, and no account needed.

The parts retail for about $16.50. On Mokxi they're free.

Nucleo analog read · STM32 Nucleo-F411RElive0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · STM32 Nucleo-F411RE
// Analog read: a potentiometer on A0.
//
// Wire the pot's ends to 3V3 and GND and its wiper to A0 (the STM32's PA0).
// analogRead gives ten bits by default, 0 to 1023 over 0 to 3.3 V, as
// STM32duino does; call analogReadResolution(12) for the ADC's full twelve.

void setup() {
  Serial.begin(115200);
}

void loop() {
  int raw = analogRead(A0);
  float volts = raw * 3.3 / 1023.0;
  Serial.print("A0 = ");
  Serial.print(raw);
  Serial.print("  (");
  Serial.print(volts, 2);
  Serial.println(" V)");
  delay(500);
}

Parts list

3 parts, plus the jumper wires. They retail for about $16.50; on Mokxi they're free.

How it is wired

3 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • STM32 Nucleo-F411RE pin 3V3; Potentiometer pin 3
  • Ground: STM32 Nucleo-F411RE pin GND; Potentiometer pin 1
  • STM32 Nucleo-F411RE pin A0; Potentiometer pin 2

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.