hello,
been trying to get a fairly simple RNG up and running.
Currently I need to generate 2 random numbers. The 1st should ideally be an int between 1 and 7, inclusive. The 2nd should be a float (with random decimals!) between 0.01 and 4.00 (ex. 2.76, 3.01, 0.44, etc), also inclusive.
I'm not sure what the problem is, but I cannot get random() to generate decimals for the 2nd value. in the serial monitor, the float is always y.00.
float x;
float y;
int z;
void setup() {
Serial.begin(9600);
randomSeed(analogRead(0));
}
void loop() {
x = random(1, 8);
y = random(0.01, 5);
z = (int)x;
Serial.println(z);
Serial.println(y);
}
So my question is:
How do I get random() (or some function) to generate random decimals??