Reading analog value


Hi, I am trying to read an analog value from Pin A1 and display it on an external monitor. However, as soon as I have an analogRead(A1) in my code the screen turns white.

Additionally, I do not get anything on my Serial Monitor.

What MCU/Processor/Board and compiler are you using?

Aduino Portenta H7 / Arduino IDE 2.0

What LVGL version are you using?


What do you want to achieve?

Being able to get values from analogRead() without the screen turning white.

What have you tried so far?

So I tried to start the analogRead later with the help of an if statement. The display turns white as soon as I tried an analogRead once. It also does not display anything anymore after I have tried to do an analogRead. If I comment out the analogRead() the code works fine.

Code to reproduce

/*You code here*/
#include "Portenta_LittleVGL.h"

static lv_obj_t *label;
static lv_obj_t *secondlabel;
int counter = 0;
int analogValue = 0;

lv_timer_t * timer;
lv_timer_t * secondtimer;

static void updateCounterTimer(lv_timer_t *timer) {
  // Print the count to the Serial monitor

  // Update the text of the label
  lv_label_set_text_fmt(label, "%d" , counter);    

  // Increase the count number

static void analogread(lv_timer_t *secondtimer) {

  analogValue = analogRead(A1);


  // Update the text of the label
  lv_label_set_text_fmt(secondlabel,"%d", analogValue);         

void setup() {  


  // Initialize Portenta's video interface

  // Setting up the label making it a child of the screen
  label = lv_label_create(lv_scr_act());
  secondlabel = lv_label_create(lv_scr_act());

  // Set the label's text
  lv_label_set_text(label , "Counter");
  lv_label_set_text(secondlabel , "Analogvalue");
  // We move it to the center of the screen and align it centered
  lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
  lv_obj_align(secondlabel, LV_ALIGN_CENTER, 0, 20);
  // Create a timer to update the counter
  timer = lv_timer_create(updateCounterTimer, 1000, NULL);
  secondtimer = lv_timer_create(analogread, 1000, NULL);

void loop() {
  // put your main code here, to run repeatedly: