Project find random number

hello I'm new to the field of arduino. I'm creating a project or I have to create a random number that I have to find.I have to type a number on my keyboard. if the number I typed is lower than the random number then a red LED lights up and if the number I typed is higher than the randomnumber a blue LED is on. if the right number is typed then both LEDs light up. Can you help me thanks in advance

Post your code. Explain what the code is supposed to do. Explain what is does instead.

at the moment I did that but it does work but I have not yet introduced the LEDs
int randNumber;
int x;
void setup() {
Serial.println(" ");
Serial.println(" Numerical guessing game ");
Serial.println(" ");
Serial.print("Devinez le nombre entre (0-10) : ");
randNumber = random(0, 10);

while(>= 0){}


void loop() {

while (Serial.available() > 0 )  {
  delay( 10 );

  x = Serial.parseInt();
  Serial.println ( x );

  Serial.println("You Win!");

  else if( x < randNumber){
   Serial.println("It's lower.");
  else if( x > randNumber){
   Serial.println("It's higher.");



That will give a number from 0 to 9. random(0, 11); for 0 to 10, inclusive.
From the Random() function reference.

max: upper bound of the random value, exclusive.

Use the IDE autoformat tool (ctrl-t or Tools, Auto Format) to indent the code for readability before posting code in code tags. See the forum guidelines.

@thieuma, your topic has been moved to a more suitable section of the forum.

You may be able to get away with reading an analog pin that is floating, and mapping that to a min, and max value. That should be pretty random assuming you aren't driving motors etc

It's not.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.