diff --git a/iameugeneyeboah/challenge_one/README.md b/iameugeneyeboah/challenge_one/README.md new file mode 100644 index 000000000..a8f8c9196 --- /dev/null +++ b/iameugeneyeboah/challenge_one/README.md @@ -0,0 +1,80 @@ +# Traffic Light System Simulation + +This project simulates a traffic light system using LEDs (Arduino version) +and a console-based simulation (Python version). +The program follows a basic traffic light sequence: + +- Red light: ON for 5 seconds +- Green light: ON for 5 seconds +- Yellow light: ON for 2 seconds + +## Features + +- **Arduino Implementation**: Controls physical LEDs connected to an Arduino board. +- **Python Simulation**: Simulates the traffic light system in the console. +- **Customizable Timing**: Light durations can be adjusted. + +--- + +## Setup Instructions + +### Arduino Implementation + +1. **Hardware Requirements**: + - Arduino board + - Red, Yellow, and Green LEDs + - Resistors (220 ohms recommended) + - Breadboard and jumper wires + +2. **Circuit Diagram**: + - Connect the Red LED to pin **13** with a resistor. + - Connect the Yellow LED to pin **12** with a resistor. + - Connect the Green LED to pin **11** with a resistor. + - Connect all LED ground ends to **GND**. + +3. **Upload Code**: + - Copy the Arduino code (see `traffic_light.ino`) into the Arduino IDE. + - Connect your board and upload the code. + +### Python Simulation + +1. **Requirements**: + - Python 3.x + - No external libraries required + +2. **Run the Code**: + - Save the Python script as `traffic_light.py`. + - Run the script in your terminal using: + + ```bash + python traffic_light.py + ``` + +--- + +## Testing + +### Test Cases + +1. **Arduino Testing**: + - Verify each LED lights up at the correct time (Red → Green → Yellow). + - Test light durations by measuring the time each light stays on. + +2. **Python Testing**: + - Ensure the console outputs match the sequence and timing. + - Modify the `time.sleep()` values to confirm timing adjustments work. + +### Test Results + +| Test Scenario | Expected Behavior +|----------------------------------------|-------------------------------------- +| Arduino lights up Red → Green → Yellow | Correct sequence followed +| Timing for each light | Red: 5s, Green: 5s, Yellow: 2s +| Python simulation sequence | Console shows correct light sequence +| Console simulation timing | Red: 5s, Green: 5s, Yellow: 2s + +## Future Improvements + +- Add a pedestrian crossing button. +- Integrate a real-time clock for dynamic timing. +- Add sound effects (buzzer) during the Yellow light phase. diff --git a/iameugeneyeboah/challenge_one/project_one.cpp b/iameugeneyeboah/challenge_one/project_one.cpp new file mode 100644 index 000000000..4050b7300 --- /dev/null +++ b/iameugeneyeboah/challenge_one/project_one.cpp @@ -0,0 +1,31 @@ +// Define LED pins +const int redLight = 13; // Red LED connected to pin 13 +const int yellowLight = 12; // Yellow LED connected to pin 12 +const int greenLight = 11; // Green LED connected to pin 11 + +void setup() { + // Set all LED pins as outputs + pinMode(redLight, OUTPUT); + pinMode(yellowLight, OUTPUT); + pinMode(greenLight, OUTPUT); +} + +void loop() { + // Turn on Red Light + digitalWrite(redLight, HIGH); + digitalWrite(yellowLight, LOW); + digitalWrite(greenLight, LOW); + delay(5000); // Wait for 5 seconds + + // Turn on Green Light + digitalWrite(redLight, LOW); + digitalWrite(yellowLight, LOW); + digitalWrite(greenLight, HIGH); + delay(5000); // Wait for 5 seconds + + // Turn on Yellow Light + digitalWrite(redLight, LOW); + digitalWrite(yellowLight, HIGH); + digitalWrite(greenLight, LOW); + delay(2000); // Wait for 2 seconds +} diff --git a/iameugeneyeboah/challenge_one/test.cpp b/iameugeneyeboah/challenge_one/test.cpp new file mode 100644 index 000000000..4c8c4995b --- /dev/null +++ b/iameugeneyeboah/challenge_one/test.cpp @@ -0,0 +1,29 @@ +#include +#include +#include // For delays + +using namespace std; + +void trafficLightSimulation() { + while (true) { + // Red Light + cout << "🔴 Red Light ON" << endl; + this_thread::sleep_for(chrono::seconds(5)); // Wait for 5 seconds + + // Green Light + cout << "🟢 Green Light ON" << endl; + this_thread::sleep_for(chrono::seconds(5)); // Wait for 5 seconds + + // Yellow Light + cout << "🟡 Yellow Light ON" << endl; + this_thread::sleep_for(chrono::seconds(2)); // Wait for 2 seconds + + cout << endl; // Add space before restarting the cycle + } +} + +int main() { + cout << "Starting Traffic Light Simulation..." << endl; + trafficLightSimulation(); + return 0; +} diff --git a/iameugeneyeboah/challenge_two/README.md b/iameugeneyeboah/challenge_two/README.md new file mode 100644 index 000000000..ace780658 --- /dev/null +++ b/iameugeneyeboah/challenge_two/README.md @@ -0,0 +1,34 @@ +# To-Do List App + +## Overview + +This is a simple To-Do List application built in Python. +The program allows users to add, view, and delete tasks from a to-do list. +The list of tasks is saved to a file (`todo.txt`) +so that the tasks persist across program runs. + +## Features + +1. **Add Task**: Allows the user to add a task with a description. +2. **View Tasks**: Displays all tasks in the to-do list. +3. **Delete Task**: Allows the user to delete a task by specifying its task number. +4. **Persist Data**: The tasks are saved in a file (`todo.txt`) +5. and are reloaded when the program restarts. + +## Technologies + +- Python 3.x +- File handling (Text file for storing tasks) + +## Setup + +1. Clone or download the repository. +2. Ensure Python 3.x is installed. +3. Run the program using a Python interpreter. + +## Usage + +- Run the program using the following command: + + ```bash + python todo_list.py diff --git a/iameugeneyeboah/challenge_two/portfolio_manager.py b/iameugeneyeboah/challenge_two/portfolio_manager.py new file mode 100644 index 000000000..46ff81c66 --- /dev/null +++ b/iameugeneyeboah/challenge_two/portfolio_manager.py @@ -0,0 +1,69 @@ +def load_tasks(filename="todo.txt"): + """Load tasks from a file.""" + try: + with open(filename, "r") as file: + tasks = file.readlines() + return [task.strip() for task in tasks] + except FileNotFoundError: + return [] + +def save_tasks(tasks, filename="todo.txt"): + """Save tasks to a file.""" + with open(filename, "w") as file: + for task in tasks: + file.write(task + "\n") + +def add_task(tasks): + """Add a new task to the list.""" + task = input("Enter the task description: ") + tasks.append(task) + save_tasks(tasks) + +def view_tasks(tasks): + """Display all tasks.""" + if tasks: + print("\nTo-Do List:") + for idx, task in enumerate(tasks, start=1): + print(f"{idx}. {task}") + else: + print("\nYour to-do list is empty.") + +def delete_task(tasks): + """Delete a task from the list.""" + try: + task_num = int(input("Enter the task number to delete: ")) + if 1 <= task_num <= len(tasks): + tasks.pop(task_num - 1) + save_tasks(tasks) + print("Task deleted successfully.") + else: + print("Invalid task number.") + except ValueError: + print("Please enter a valid number.") + +def main(): + tasks = load_tasks() + + while True: + print("\nTo-Do List Menu:") + print("1. Add Task") + print("2. View Tasks") + print("3. Delete Task") + print("4. Exit") + + choice = input("Choose an option: ") + + if choice == '1': + add_task(tasks) + elif choice == '2': + view_tasks(tasks) + elif choice == '3': + delete_task(tasks) + elif choice == '4': + print("Goodbye!") + break + else: + print("Invalid choice. Please try again.") + +if __name__ == "__main__": + main()