button quetion

i have arduino uno , lcd , and some buttons . i want that appears on screen 3 questions , and then , wait for button pressed to select one !

this is my code until now ... :

{ delay (2000); Serial.begin (115200); lcd.clearLCD(); Serial.print("chose one"); delay (1000); lcd.gotoLine(7); Serial.print("1 -Easy"); delay (1000); lcd.gotoLine(6); Serial.print("2 -Med"); delay (1000); lcd.gotoLine(5); Serial.print("3 -Hard");

if (digitalRead(7) == 0 ) { delay (2000); Serial.begin (115200); lcd.clearLCD(); Serial.print(" MOD easy"); delay (9999); } if (digitalRead (8) == 0 ) { delay (2000); Serial.begin (115200); lcd.clearLCD(); Serial.print(" MOD MED"); delay (9999); } if (digitalRead (10) == 0 ) { delay (2000); Serial.begin (115200); lcd.clearLCD(); Serial.print (" MOD hard"); delay (9999); } }

thanks guys :D

Hello !

It’s better that you use the code formatted window to post your code and post the entire sketch. I guess more people are able to help this way.

snip2.jpg

Go ahead and post the rest of the program, otherwise nobody can tell if it is part of loop() or setup(). At any rate, you only need one Serial.begin() function call in your program. Not sure why a smiley is showing up in the second digitalRead() call. Need to see how you are setting those pins up too.

The smiley's there because it's not in code tags and the number 8 followed by a ) as it must have been in that line of code, is a 8) in normal text display.

the complete code is here :

#include <serialGLCD.h>
serialGLCD lcd;

void setup()
{

{
pinMode (3, INPUT);
digitalWrite (3, 1);
pinMode (5, INPUT);
digitalWrite (5, 1 );
pinMode (7, INPUT);
digitalWrite (7, 1);
pinMode (8, INPUT);
digitalWrite (8, 1);
pinMode (10, INPUT);
digitalWrite (10, 1);
pinMode (12, INPUT);
digitalWrite (12, 1);
}

{
Serial.begin (115200);
lcd.clearLCD ();
Serial.print (" QUIZ GAME");
Serial.print (" “);
Serial.print (” INFORMATICA");
delay (5000);
lcd.clearLCD();
delay (1000);
}

do
{
lcd.gotoLine(4);
Serial.print (" ok to continu");
delay (1000);
lcd.clearLCD();
}while (digitalRead(5) == 1 );

}

void loop ()
{

{
delay (2000);
Serial.begin (115200);
lcd.clearLCD();
Serial.print(“CHOSE ONE”);
delay (1000);
lcd.gotoLine(7);
Serial.print(“1 -EASY”);
delay (1000);
lcd.gotoLine(6);
Serial.print(“2 -MED”);
delay (1000);
lcd.gotoLine(5);
Serial.print(“3 -HARD”);

if (digitalRead(7) == 0 )
{
delay (2000);
Serial.begin (115200);
lcd.clearLCD();
Serial.print(" MOD EASY");
delay (9999);
}
if (digitalRead (8) == 0 )
{
delay (2000);
Serial.begin (115200);
lcd.clearLCD();
Serial.print(" MOD MED");
delay (9999);
}
if (digitalRead (10) == 0 )
{
delay (2000);
Serial.begin (115200);
lcd.clearLCD();
Serial.print (" MOD HARD");
delay (9999);
}

}

}

#include <serialGLCD.h>
serialGLCD lcd;


void setup()
{


  {
  pinMode (3, INPUT);
  digitalWrite (3, 1);
  pinMode (5, INPUT);
  digitalWrite (5, 1 );
  pinMode (7, INPUT);
  digitalWrite (7, 1);
  pinMode (8, INPUT);
  digitalWrite (8, 1);
  pinMode (10, INPUT);
  digitalWrite (10, 1);
  pinMode (12, INPUT);
  digitalWrite (12, 1);
  }

  {
  Serial.begin (115200);
  lcd.clearLCD ();
  Serial.print ("       QUIZ GAME");
  Serial.print ("                     ");
  Serial.print ("         INFORMATICA");
  delay (5000);
  lcd.clearLCD();
  delay (1000);
  }
 
 
 
  do
  {
  lcd.gotoLine(4);
  Serial.print (" ok to continu");
  delay (1000);
  lcd.clearLCD();
  }while (digitalRead(5) == 1 );


}



void loop ()
{
  


   {
    delay (2000);
    Serial.begin (115200);
    lcd.clearLCD();
    Serial.print("CHOSE ONE");
    delay (1000);
    lcd.gotoLine(7);
    Serial.print("1 -EASY");
    delay (1000);
    lcd.gotoLine(6);
    Serial.print("2 -MED");
    delay (1000);
    lcd.gotoLine(5);
    Serial.print("3 -HARD");
    
    
    if (digitalRead(7) == 0 ) 
       {
         delay (2000);
         Serial.begin (115200);
         lcd.clearLCD();
         Serial.print("     MOD EASY");
         delay (9999);
       }
    if (digitalRead ( == 0 )
       {
         delay (2000);
         Serial.begin (115200);
         lcd.clearLCD();
         Serial.print("     MOD MED");
         delay (9999);
       }
    if (digitalRead (10) == 0 )
       {
         delay (2000);
         Serial.begin (115200);
         lcd.clearLCD();
         Serial.print ("    MOD HARD");
         delay (9999);
       }
    
   
    
    
   }
 
}