I am very new to Arduino and for my principles of engineering final project, we are making an alarm clock that includes a LCD screen, RTC, force sensor, a push button, buzzer and 2 sound recorders. the goal of this project is to create a way to get out of bed to start the day. there are a couple different parts to this project, one being the LCD screen display of a RTC, the second part being a 2 XLW sound module and a buzzer, and the final part being a force sensor that shuts everything off when it has a certain number of pressure applied. whats supposed to happen is when the time hits "00" seconds, the first audio titled "Bball" will play until a push button is pressed, where a second audio titled "Scream" plays, until the button is pressed again, which turns on a buzzer, and that only stops when you apply pressure to the force sensor over 900. the problem seems to occur with the XLW sound modules and buzzer, skipping over the first sound player and then also ignoring the button in between the second sound and buzzer. the LCD screen also freezes when ever the XLW sound module starts playing and does not unfreeze until the recording stops. i know that this is a software issue, but i cant figure out what the bug might be. please i need help. why isn't my Arduino code working and how can I fix it?
here is my current code
#include <Wire.h>
#include <RTClib.h>
#include <LiquidCrystal_I2C.h>
int buzzerPin = 8;
int sensorPin = A0; // set photoresistor pin
int led1Pin = 9; // set LED pin
int sensorValue; // store photoresistor reading
boolean PressureOn;
RTC_DS3231 rtc;
LiquidCrystal_I2C lcd(0x27, 16, 2); // Address 0x27 is common
int Scream = 5;
int Bball = 3;
int readPin = 10;
boolean ScreamOn;
boolean BballOn;
void setup() {
Serial.begin(9600);
lcd.init();
lcd.backlight();
if (!rtc.begin()) {
lcd.print("RTC not found!");
while (1)
;
}
// Sets RTC to the computer's time at upload (run once)
if (rtc.lostPower()) {
rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
// put your setup code here, to run once:
pinMode(buzzerPin, OUTPUT);
pinMode(led1Pin, OUTPUT);
Serial.begin(9600);
Serial.println("Program Starting..");
pinMode(Bball, OUTPUT);
pinMode(Scream, OUTPUT);
pinMode(readPin, INPUT);
digitalWrite(Bball, LOW);
digitalWrite(Scream, LOW);
ScreamOn = true;
BballOn = true;
}
void loop() {
DateTime now = rtc.now();
lcd.setCursor(0, 0);
lcd.print("Date: ");
lcd.print(now.month());
lcd.print('/');
lcd.print(now.day());
lcd.print('/');
lcd.print(now.year());
lcd.setCursor(0, 1);
lcd.print("Time: ");
if (now.hour() < 10) lcd.print('0');
lcd.print(now.hour());
lcd.print(':');
if (now.minute() < 10) lcd.print('0');
lcd.print(now.minute());
lcd.print(':');
if (now.second() < 10) lcd.print('0');
lcd.print(now.second());
delay(1000);
if (sensorValue >= 900) {
digitalWrite(led1Pin, HIGH);
} else {
digitalWrite(led1Pin, LOW);
}
if (now.second() == 00) {
digitalWrite(Bball, HIGH);
delay(200);
digitalWrite(Bball, LOW);
while (digitalRead(readPin) == LOW) {
sensorValue = analogRead(sensorPin); //read pressure
if (sensorValue >= 900) {
PressureOn = true;
digitalWrite(led1Pin, HIGH);
break;
}
}
//stop bball
digitalWrite(Bball, HIGH);
delay(200);
digitalWrite(Bball, LOW);
//start scream
digitalWrite(Scream, HIGH);
delay(200);
digitalWrite(Scream, LOW);
while (digitalRead(readPin) == LOW && PressureOn == false) {
sensorValue = analogRead(sensorPin); //read pressure
if (sensorValue >= 900) {
PressureOn = true;
digitalWrite(led1Pin, HIGH);
break;
}
}
digitalWrite(Scream, HIGH);
delay(200);
digitalWrite(Scream, LOW);
digitalWrite(buzzerPin, HIGH);
while (analogRead(sensorPin) <= 900 && PressureOn == false) {
}
PressureOn = true;
digitalWrite(led1Pin, HIGH);
digitalWrite(buzzerPin, LOW);
(PressureOn = false);
}
}
this is a description of how the hardware is set up.
this is a flow chart of what I want to happen



