4 years, 6 months ago.

7 Segment display random number

How does this code generate a random number on a 7 segment display? Confused about p20...

  1. include "mbed.h" AnalogIn analog(p20); int main() { srand(analog.read_u16()); int x = rand()%10; return 0;

}end of int main

1 Answer

4 years, 5 months ago.

Hi Antonios,

From the code snippet, what I see is that the random seed is using value read from AnalogIn, so that we can get a random number by rand().

Regards, Desmond