This project is a simple alarm clock program written in C. It allows users to set, cancel, and monitor alarms based on a 12-hour format with AM/PM notation. The program provides a text-based menu interface for interacting with the alarm system and an ongoing loop to check and activate alarms as needed.
- Set Alarms: Configure alarms with a specific hour, minute, second, and AM/PM period.
- Cancel Alarms: Remove alarms from the active list.
- View Alarms: Display all currently set alarms.
- Monitor Alarms: Continuously check and trigger alarms at their scheduled times.
- User Interface: Simple menu-driven interface for ease of use.
- A C compiler (e.g., GCC)
- Basic understanding of how to compile and run C programs
-
Clone the Repository: Download the source code from the repository.
git clone https://github.com/mdriyadkhan585/alarm-clock-C cd alarm-clock-C
-
Compile the Program: Use a C compiler to compile the source code. For GCC, you can use:
gcc -o alarm_clock alarm_clock.c
-
Run the Program: Execute the compiled program:
./alarm_clock
Upon running the program, you will be presented with the main menu. Here are the available options:
-
Set Alarm: Configure a new alarm.
- Hour (1-12): Enter the hour in 12-hour format.
- Minute (0-59): Enter the minute.
- Second (0-59): Enter the second.
- AM/PM (A/P): Specify AM or PM.
Example:
Enter alarm time (12-hour format): Hour (1-12): 7 Minute (30): 15 Second (0): 0 AM/PM (A/P): A
-
Cancel Alarm: Remove an existing alarm.
- View the list of active alarms.
- Enter the number of the alarm you wish to cancel.
Example:
Enter the number of the alarm to cancel: 1
-
Show Alarms: Display all currently set alarms.
- A list of all active alarms will be shown with their respective times.
-
Done: Finalize alarm setup and start the monitoring process.
- When you choose "Done", the program will exit the menu and start monitoring for active alarms.
- Alarm Monitoring: After choosing "Done", the program enters an ongoing loop where it continuously checks the current time against the set alarms.
- Alarm Activation: When the system time matches the time of an active alarm, the alarm will trigger, and a message will be displayed.
- Alarm Deactivation: Once triggered, the alarm will be deactivated automatically to prevent multiple triggers.
Current time: 12:34:56
Options:
1. Set Alarm
2. Cancel Alarm
3. Show Alarms
4. Done
Choose an option: 1
Enter alarm time (12-hour format):
Hour (1-12): 6
Minute (30): 0
Second (0): 0
AM/PM (A/P): P
Alarm set for 06:30:00 PM
Options:
1. Set Alarm
2. Cancel Alarm
3. Show Alarms
4. Done
Choose an option: 4
Starting alarm...
- Invalid Input: If you enter invalid data (e.g., an hour outside 1-12), the program will prompt you to enter valid values.
- Program Not Starting: Ensure you have compiled the program correctly and have the necessary permissions to execute it.
Feel free to contribute to this project by submitting issues or pull requests. To contribute:
- Fork the repository.
- Create a new branch for your changes.
- Make your modifications and commit them.
- Submit a pull request for review.