Hi guys,
I can get a rand number use the API:err_code = sd_rand_application_vector_get(buf, bytes_available); but the question is that How can I get a rand number just between 0 to 9 use the RANG Module.
Hi guys,
I can get a rand number use the API:err_code = sd_rand_application_vector_get(buf, bytes_available); but the question is that How can I get a rand number just between 0 to 9 use the RANG Module.
Get as many bytes as you wish to make a uint8_t, uint16_t or uint32_t then mod it (%) with 10 to get a number from 0-9. uint8_t will show a slight bias for 0-6 (about 2%), at 16 bits it's about .01% and by 32 bits the bias is negligible assuming the bytes truly are random, which I believe the spec claims them to be.
Thank you very much