This is a very general question. I will give some more overview. After that you have to ask specific questions about certain lines of code
The code does a lot of serial output so you should activate the serial monitor in the arduino-IDE and then watch what happends if you run the code.
You have to connect a push-button between ground and A0 to make the code react on the push-button-pressing
GetToggleSwitchState()
does what its name says
this function has a return-value.
You can assign a variable a value
myVar = 10;
a function that has a return-value can be used to assign this value to a variable
This is what is happening here
activationMode = GetToggleSwitchState(); // must be executed all the time
assign the variable with name "activationMode" the return-value of function GetToggleSwitchState()
Which is either value "true" or value "false"
function
execute_if_Active(activationMode);
is handed over this value in the parenthesis
so the function call is either
execute_if_Active(true);
or
execute_if_Active(false);
function execute_if_Active() does what its name says
void execute_if_Active(bool p_IsActivated) {
printActionState(p_IsActivated); // for demonstration purposes only
if (p_IsActivated) {
my_Action();
}
}
function printActionState() does what its name says
the if-condition
if (p_IsActivated) {
my_Action();
}
gets handed over the value "true" or "false" inside parameter p_isActivated
this means
if (true) {
my_Action();
}
then function my_Action() is executed
or
if (false) {
my_Action();
}
function my_Action() will NOT be executed
you put the code that you want to be executed only if mode is "active" inside function
my_Action() ;
you can jump over the
the lines inside functions
GetToggleSwitchState()
and
TimePeriodIsOver()
as the only thing you use directly is the function-call
activationMode = GetToggleSwitchState();
If you find this still very hard to understand your knowledge-level is very low and I highly recommend that you work through this tutorial
You will have a lot of AHA!-Moments
Take a look into this tutorial:
Arduino Programming Course
It is easy to understand and has a good mixture between explaining important concepts and example-codes to get you going. So give it a try and report your opinion about this tutorial.
You can avoid learning the basics but then you will go on having a hard time to write code
So look into the toggleswitch-example again and post a suggestion what you think
where
inside this code you would have to put the blinking of YOUR led
best regards Stefan