IR Remote & Servo Motor

you have 4 simple states your system can be into:

  • waiting for a IR command (0xBA45FF00)
  • moving to 100° (it's quite fast with a servo)
  • resting for 3 seconds
  • returning to 0° (it's quite fast too)

The events you need to deal with are obviously the IR code when you are waiting for the command and then just time passing using millis.

This could be either a very sequential code (in pseudo code)

void loop() {
  if (IR signal received) {
    move servo to 100°
    delay 3000ms
    move servo to 0°    
  }
}

or if you want non blocking code (so that you could still do other stuff while waiting for 3s) you might benefit from studying state machines. Here is a small introduction to the topic: Yet another Finite State Machine introduction