trying to create slot machine. after generation of random number my idea is to compare the result and display it on LCD screen!
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);
}
}
Hope this helps!
Have a great day,
Jennie Zhang
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Thank You Zhang!
It seems to be a good idea I will give it a try!
On Mon, Dec 12, 2016 at 2:46 AM, ZhangJennie <admin@community.nxp.com>