Browse Source

main.cpp modified to control the four user LEDs and help added to terminal

master
gustavo96 2 years ago
parent
commit
a60ef1e5a2
1 changed files with 28 additions and 16 deletions
  1. +28
    -16
      main.cpp

+ 28
- 16
main.cpp View File

@ -3,24 +3,36 @@
using namespace std;
int main(int argc, char* argv[]){
CLED led1 = CLED(3);
string cmd(argv[1]);
if(argc!=2)
std::cout << "Incorrect number of arguments" << std::endl;
if(cmd=="on")
led1.TurnOn();
else if(cmd=="off")
led1.TurnOff();
else if(cmd=="blink")
led1.BlinkLED();
else
cout << "Invalid command" << endl;
if(argc!=2){
std::cout << "Error: This is not a command for this application" << std::endl;
std::cout << "These are the commands you can use: on, off and blink" << std::endl;
}
std::cout << "Starting app" << std::endl;
string cmd(argv[1]);
CLED leds[4] = {CLED(0), CLED(1), CLED(2), CLED(3)};
for(int i=0; i<=3; i++){
if(cmd=="on")
leds[i].TurnOn();
else if(cmd=="off")
leds[i].TurnOff();
else if(cmd=="blink")
leds[i].BlinkLED();
else{
std::cout << "Error: Invalid command" << std::endl;
std::cout << "These are the commands you can use: " << std::endl;
std::cout << "on - Powers on the LED" << std::endl;
std::cout << "off - Powers off the LED" << std::endl;
std::cout << "blink - Makes the LED blink" << std::endl;
}
}
return 0;
}

Loading…
Cancel
Save