Hi I want to improve on project 11 by making it return random answers to each line, not just the bottom line, but I'm not getting the result I want.
So far I've only be able to get both lines to return random answers that are seemingly permanently paired. Can anyone help me find an answer to this?
For example, the answers are always return like this:
Case 1
Case 1
or
Case 3
Case 3
What I want to achieve is:
Case 1
Case 5
or
Case 7
Case 3
The original code:
void loop() {
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
reply = random( 8 );
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("the ball says:");
lcd.setCursor(0, 1);
switch (reply) {
case 0:
lcd.print("Yes");
break;
case 1:
lcd.print("Most likely");
break;
...continues...
case 7:
lcd.print("No");
break;
}
}
}
prevSwitchState = switchState;
}
And the changes I made:
void loop() {
switchState = digitalRead(switchPin);
if (switchState != prevSwitchState) {
if (switchState == LOW) {
reply = random( 8 );
lcd.clear();
lcd.setCursor(0, 0);
switch(reply){
case 0:
lcd.print("Yes");
break;
case 1:
lcd.print("Most likely");
break;
...continues...
case 7:
lcd.print("No");
break;
}
lcd.setCursor(0, 1);
switch(reply){
case 0:
lcd.print("Yes");
break;
case 1:
lcd.print("Most likely");
break;
...continues...
case 7:
lcd.print("No");
break;
}
}
}
prevSwitchState = switchState;
}