```pytho n
from machine import Pin, PWM
import time
import urandom
import machine
# Class for handling IR Remote, LEDs, and Servo Motor
class IRRemoteProject:
def __init__(self):
# Initialize IR receiver
self.ir_pin = Pin(15, Pin.IN)
self.ir_pin.irq(trigger=Pin.IRQ_FALLING, handler=self.handle_ir)
# Initialize LEDs
self.blue_led = Pin(13, Pin.OUT)
self.purple_led = Pin(14, Pin.OUT)
# Initialize Servo
self.servo = PWM(Pin(16))
self.servo.freq(50)
# IR command dictionary
self.ir_commands = {
'0x1FE50AF': self.print_phrase_1,
'0x1FE10EF': self.print_phrase_2,
'0x1FE906F': self.print_phrase_3,
'0x1FE30CF': self.print_phrase_4,
'0x1FEB04F': self.print_phrase_5,
'0x1FE708F': self.print_phrase_6,
'0x1FE00FF': self.print_phrase_7,
'0x1FEF00F': self.print_phrase_8,
'0x1FE9867': self.print_phrase_9,
'0x1FEA857': self.move_servo,
'0x1FEA05F': self.light_purple_led,
'0x1FE609F': self.light_blue_led
}
# Previous time to debounce IR input
self.last_time = time.ticks_ms()
def handle_ir(self, pin):
current_time = time.ticks_ms()
if time.ticks_diff(current_time, self.last_time) > 100:
self.last_time = current_time
ir_code = self.decode_ir()
if ir_code:
self.execute_command(ir_code)
def decode_ir(self):
# Dummy implementation to simulate IR code reading
# Replace with actual IR decoding logic
return urandom.choice(list(self.ir_commands.keys()))
def execute_command(self, ir_code):
command = self.ir_commands.get(ir_code)
if command:
command()
def print_phrase_1(self):
print("Phrase 1")
def print_phrase_2(self):
print("Phrase 2")
def print_phrase_3(self):
print("Phrase 3")
def print_phrase_4(self):
print("Phrase 4")
def print_phrase_5(self):
print("Phrase 5")
def print_phrase_6(self):
print("Phrase 6")
def print_phrase_7(self):
print("Phrase 7")
def print_phrase_8(self):
print("Phrase 8")
def print_phrase_9(self):
print("Phrase 9")
def move_servo(self):
self.servo.duty_ns(1500000) # Move servo to 90 degrees
time.sleep(1)
self.servo.duty_ns(500000) # Move servo to 0 degrees
def light_purple_led(self):
self.purple_led.on()
time.sleep(0.5)
self.purple_led.off()
def light_blue_led(self):
self.blue_led.on()
time.sleep(0.5)
self.blue_led.off()
# Main execution
project = IRRemoteProject()
# Keep the program running
while True:
time.sleep(1)
```