#include "LEDControl.h" 
#include "ButtonControl.h" 

void setup() {
  Serial.begin(9600); // Initialize serial communication at 9600 baud rate for data exchange between the Arduino and the computer
  Serial.println("Popescu Nichifor FAF-212 lab1.1"); 
  Serial.println("Serial Monitor ");
  Serial.println("---------------------------------"); 
  setupLED(); // function that initialize the LED pin as an output
  setupButton(); // function to initialize the button pin as an input
}

void loop() {
  if (Serial.available() > 0) { // if there is data available to read from the Serial buffer
    String command = Serial.readStringUntil('\n'); 
    if (command == "led on") { 
      turnOnLED(); 
    } else if (command == "led off") { 
      turnOffLED(); 
    } else if (command == "toggle") { 
      toggleLED(); 
    } else { 
      Serial.println("Invalid command. Use 'led on', 'led off', or 'toggle'."); 
    }
  }
  
  if (checkButton()) { 
    toggleLED(); 
  }
}