Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: **Task Tracker**
- - Source Code NOT compiled for: Arduino Uno
- - Source Code created on: 2024-12-15 05:40:02
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Design a simple task management system that will */
- /* allow the user to manage their daily tasks. The */
- /* program will present the user with options to: • */
- /* Add new tasks • Mark tasks as complete • View */
- /* their task list, with completed tasks clearly */
- /* marked. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <Wire.h> // Include Wire library for I2C
- #include <SPI.h> // Include SPI library for SPI communication
- #include <Servo.h> // Include Servo library for controlling servos
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void addTask(String task);
- void markTaskComplete(int taskIndex);
- void viewTasks();
- /****** GLOBAL VARIABLES *****/
- const int MAX_TASKS = 10; // Maximum number of tasks
- String tasks[MAX_TASKS]; // Array to store tasks
- bool taskCompleted[MAX_TASKS]; // Array to track completed tasks
- int taskCount = 0; // Current number of tasks
- void setup(void)
- {
- // Initialize serial communication for debugging
- Serial.begin(9600);
- Serial.println("Task Management System Initialized");
- }
- void loop(void)
- {
- // Simulate adding tasks and marking them complete
- addTask("Task 1");
- addTask("Task 2");
- markTaskComplete(0); // Mark Task 1 as complete
- viewTasks(); // View the current list of tasks
- delay(5000); // Delay for demonstration purposes
- }
- // Function to add a new task
- void addTask(String task) {
- if (taskCount < MAX_TASKS) {
- tasks[taskCount] = task;
- taskCompleted[taskCount] = false; // Task is initially not completed
- taskCount++;
- Serial.println("Added: " + task);
- } else {
- Serial.println("Task list is full. Cannot add more tasks.");
- }
- }
- // Function to mark a task as complete
- void markTaskComplete(int taskIndex) {
- if (taskIndex >= 0 && taskIndex < taskCount) {
- taskCompleted[taskIndex] = true;
- Serial.println("Marked task " + String(taskIndex) + " as complete.");
- } else {
- Serial.println("Invalid task index.");
- }
- }
- // Function to view all tasks
- void viewTasks() {
- Serial.println("Current Tasks:");
- for (int i = 0; i < taskCount; i++) {
- String status = taskCompleted[i] ? " [Completed]" : " [Pending]";
- Serial.println(String(i) + ": " + tasks[i] + status);
- }
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement