Hi,
CW stdlib includes rand() function that generates a pseudo-random integer value.
then you can use sprintf() to print a number to string then post string to LCD
see this code
#include <stdlib.h>
#include <stdio.h>
void main(void) {
volatile int n;
int i;
char to_lcd[50];
unsigned int seed;
for (seed = 1; seed <5; seed++) {
srand(seed);
n=rand();
sprintf(to_lcd, "%d", n);
}
}
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------