Logic of the program.
Would you please explain the if condition of the program and why was it used? Also why we are using digitalWrite in the conditional loop and also what does "if fwdbuttonstate==LOW?ICpin2" and "if fwdbuttonstate==LOW?ICpin7" means??
Arduino Pulse-Width-Modulation 09-10 min 40-50 sec
The IF condition of this program checks whether the push button is pressed or not. Depending upon the low or high state, the code executes.
The reason behind using digitalWrite in conditional loop is once the button is pressed and the motor rotates clockwise / anti clockwise, it should stop rotating when we release the push button. So that when the next input is given to the controller it will take new value and rotate accordingly.
And about the last part of your question, the code checks whether the fwdbutton state is LOW or high, if it is LOW then ICpin2 or ICpin7 (whichever is assigned to the line of code) will be triggered and the motor will rotate accordingly.