Create a class LED that represents a simple LED connected to a microcontroller GPIO pin.
Your class must:
int pin → GPIO pin number (non-negative integer)int state → LED state (0 = OFF, 1 = ON)void on() → sets the LED state to 1void off() → sets the LED state to 0void toggle() → flips the LED state (0 ↔ 1)int status() → returns the current LED state (0 or 1)main():pin → GPIO pin numberinitialState → initial LED state (0 or 1 only)toggleCount → number of times to toggle the LED (≥ 0)LED object using the given pininitialStatetoggle() exactly toggleCount times0 or 1) using status()Example Input:
5
1
3
Example Output:
0
Explanation:
Start ON → toggle 3 times → OFF
Constraints:
initialState is guaranteed to be either 0 or 1toggleCount is guaranteed to be a non-negative integerstate and pin must be privatestate0 or 1
Input
5 1 3
Expected Output
0