im trying to get a random eye color but it always gives e the middle one
#include <LiquidCrystal.h>
const char* color={“blue eyes”,“green eyes”,“red eyes”};
const char* str = color[random(3)];
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
lcd.begin(16, 2);
}
void loop() {
lcd.print(str);
lcd.setCursor(0, 1);
}
Do you understand that the random() function will generate the same series of "random" numbers each time it is used unless you use the randomSeed() function first ?
The challenge is to create a random number to seed the sequence with. An often suggested solution is to use the value from a floating analogue pin using analogRead()
read how to use this forum and make ur code, into code read part 6
Starting from reset, random() always gives the same sequence of numbers.
It should not be used for initialization of variables.
Random character and random string selection illustrated below:
make ur code, into code read part 6