Can someone help me to improve my code? IR remote control to control Motor

Very nice. Even better, you did the work. Have fun!

[edit]By the way... you just created a "finite state machine" (FSM) that does not rely on an action ("the button IS pressed") rather the action occurred ("the button WAS pressed") and then you changed states of the "infinite" flag. You will use FSM quite a bit when controlling devices. This is one example, but I would recommend finding other points of view on the FSM...

2 Likes