Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

Unable to see LED toggling (programming MCU in C++) ?

+1 vote
asked Dec 12, 2021 by Areeb Sherjil (1,960 points)

I made this code that turns off all LEDs and then deletes data. Upon deleting the data it turns on the green LEDs. However, when the code runs the user cannot 'see' the green leds turning off and then on. Is this because the MCU does these commands so fast that a human eye cannot see it?

void Calculator::calculate(Process& P,Results& R)

{

uint32_t total= P.ProcessRow();

/* Other code to be ignored */

else

{

GPIOE->ODR = GPIOE->ODR & ~((uint16_t) ALL_PINS);// turn of All LEDs

R.StoreResult(total);

P.NextRow();

R.EmptyResults();

LED[1].toggle(); // green LEDs toggling

LED[5].toggle();

}

}

1 Answer

0 votes
answered Dec 12, 2021 by Peter Minarik (84,720 points)
Yes, it is highly likely that the LEDs turn off and on again quicker than the human eye can react.

You can test it by delaying between the turning off and on again.
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...