Help with Arduino project 11 Crystal ball.

:o Hi guys, I was wondering if there is a command that would allow screen to go back onto:
"Ask the super Johnnycash" a few second after question has been answered?
Thanks for your help!
Here is the code:

#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2); 
const int switchPin = 6;
int switchState = 0;
int prevSwitchState = 0;
int reply;
void setup() {
 lcd.begin(16, 2);
 pinMode(switchPin, INPUT);
 lcd.print("Ask the super"); //10
 lcd.setCursor(0, 1);
 lcd.print("Johnnycash");
}
void loop() {
 switchState = digitalRead(switchPin);
 if (switchState != prevSwitchState){
   if (switchState ==LOW) {
     reply = random(8 );
     lcd.clear();
     lcd.setCursor(0, 0); //20
     lcd.print("Super Johnny says:");
     lcd.setCursor(0, 1);
     switch(reply){
       case 0:
       lcd.print("No =(");
       break;
       case 1:
       lcd.print("Most likely");
       break;
       case 2: //30
       lcd.print("Certainly");
       break;
       case 3:
       lcd.print("outlook Good");
       break;
       case 4:
       lcd.print("Unsure");
       break;
       case 5:
       lcd.print("Ask again");  //40
       break;
       case 6:
       lcd.print("Doubtfull");
       break;
       case 7:
       lcd.print("Yes =)");
       break;
     }
   }
 } //50
 prevSwitchState = switchState;
}

Thanks!

You are more likely to get people to read your code if you go back and edit your post to use "code" tags. That will make the code a lot more readable.

Don

thanks a lot bud.

Johny_Cash:
:o Hi guys, I was wondering if there is a command that would allow screen to go back onto:
"Ask the super Johnnycash" a few second after question has been answered?
Thanks for your help!

Thanks!

unsigned long timeout;

void prompt_question(){
 lcd.clear();
 lcd.print("Ask the super"); //10
 lcd.setCursor(0, 1);
 lcd.print("Johnnycash");
 timeout=0;
}

void setup(){
//init
prompt_question();
}

void loop(){
// stuff
if((timeout!=0)&&(millis()>timeout)) prompt_question();

if(keypressed){
// stuff
  timeout=millis()+10000; // display answer ten seconds.
   }// end of if
}

Chuck.


Check out my Kickstarter Project Memory Panes an expansion RAM Shield for Mega2560's. It adds 1MB of RAM for those projects where 8KB is not enough.