I'm writing on a code for a game, I'm just at the beginning with the writing but I have a problem...For the beginning of the game I thought of making an Intro with lights, sounds and on the LCD Display it says: Strat Fighters! (the name of the game). After that it should show something on the display like Player 1. But after the sounds etc. the display just cleares. I tried putting the command (lcd.print("Player 1")) after the sounds in the void intro, after the void intro in the loop and it still doesn't function. It just skips the command. I tried and put a command for turning on an LED an that function, but the lcd.print just gets skipped. How can that be? Thanks for your help!
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int led_gelb = 7;
int led_grun = 8;
int led_blau = 9;
int led_rot = 10;
int buzzer_one = 1;
int buzzer_two = 0;
int buzzer_three = 13;
int speaker = 6;
int one_status;
int two_status;
int three_status;
int health_gelb;
int health_grun;
int health_blau;
int health_rot;
int spieler_dran;
int win_a;
int win_b;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(led_gelb, OUTPUT);
pinMode(led_grun, OUTPUT);
pinMode(led_blau, OUTPUT);
pinMode(led_rot, OUTPUT);
pinMode(buzzer_one, INPUT_PULLUP);
pinMode(buzzer_two, INPUT_PULLUP);
pinMode(buzzer_three, INPUT_PULLUP);
pinMode(speaker, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
lcd.clear();
win_a = false;
win_b = false;
one_status = digitalRead(buzzer_one);
two_status = digitalRead(buzzer_two);
three_status = digitalRead(buzzer_three);
//Wenn beide Buttons gedrückt sind startet das Spiel
if (one_status == LOW && three_status == LOW) {
intro();
lcd.print("Player 1");
digitalWrite(led_gelb, HIGH);
}
}
void intro() {
//INTRO MIT LICHTERN UND SOUND
lcd.setCursor(0, 0);
lcd.print("STRAT FIGHTERS!");
digitalWrite(led_gelb, HIGH);
tone(speaker, 63);
delay(150);
digitalWrite(led_grun, HIGH);
tone(speaker, 126);
delay(150);
digitalWrite(led_blau, HIGH);
tone(speaker, 189);
delay(150);
digitalWrite(led_rot, HIGH);
tone(speaker, 255);
delay(150);
digitalWrite(led_rot, LOW);
tone(speaker, 189);
delay(150);
digitalWrite(led_blau, LOW);
tone(speaker, 126);
delay(150);
digitalWrite(led_grun, LOW);
tone(speaker, 63);
delay(150);
digitalWrite(led_gelb, LOW);
noTone(speaker);
delay(750);
digitalWrite(led_gelb, HIGH);
digitalWrite(led_grun, HIGH);
digitalWrite(led_blau, HIGH);
digitalWrite(led_rot, HIGH);
tone(speaker, 255);
delay(1500);
noTone(speaker);
digitalWrite(led_gelb, LOW);
digitalWrite(led_grun, LOW);
digitalWrite(led_blau, LOW);
digitalWrite(led_rot, LOW);
lcd.clear();
}