a friend and I are trying to write a game that needs to ask for random inputs but the

random(0, 3)

function gives us the same series every time. my friend thinks we need to get a random seed but we can’t figure out how to!

please help!

Your friend is right.

See:random() - Arduino Reference


Read in the microsec() value, which is the number of usec since the program started, then use the modulo function (%) to bring it down to some reasonable range. If you wait until some user input occurs,
micros()%1000 would give you 1000 different seeds, not likely to be very predictable in advance.

Good Luck.

Thanks! were starting off just as a proof of concept of 3 pins but our second one is far more common and always is the first one. weve been testing it for an hour… heres our code

void askForInput (int player) {
if (timer_1 <= 0)
numRandom1 = random(0, 3);
CurrentTask1 = numRandom1;
Amount += 1;

Using the time between startup and the first button press, in micros, is a good starter but don't use "modulo" there's no need to "reduce" the value to something "reasonable".

After that use other "random" inputs to move the random number generator on - don't give it a new seed.

For example take the time between button presses and call random that number of times, throw away all but the last result to get your next random value.