From 0a4bb8a01eeecb34a1fc259482751df256aa5edf Mon Sep 17 00:00:00 2001 From: Kattni Rembor Date: Thu, 26 Jul 2018 14:29:18 -0400 Subject: [PATCH] Moved IR codes to variables --- .../ZombieGame.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Circuit_Playground_Express_IR_Zombie_Game/ZombieGame.py b/Circuit_Playground_Express_IR_Zombie_Game/ZombieGame.py index e13e9dd0..86812626 100755 --- a/Circuit_Playground_Express_IR_Zombie_Game/ZombieGame.py +++ b/Circuit_Playground_Express_IR_Zombie_Game/ZombieGame.py @@ -34,8 +34,12 @@ zombie_led_pulse = 0.07 pixels.brightness = 0.0 # Change to set number of seconds between each signal being sent. -ZOMBIE_TIME = 3 HEALER_TIME = 1 +ZOMBIE_TIME = 3 + +# The Healer and Zombie IR signal codes +HEALER_IR = [72, 69, 65, 76] +ZOMBIE_IR = [90, 79, 77, 66] human_health_counter = 10 human = 0 @@ -70,7 +74,7 @@ while True: # Something got distorted or maybe its not an NEC-type remote? continue print("NEC Infrared code received: ", received_code) - if received_code == [10, 10, 10, 10]: + if received_code == ZOMBIE_IR: print("Zombie code received!") pixels.fill(0) human_health_counter -= 1 @@ -80,7 +84,7 @@ while True: mode = zombie pixels.fill((255, 0, 0)) print("Zombified!") - if received_code == [20, 20, 20, 20]: + if received_code == HEALER_IR: print("Healer code received!") if human_health_counter < 10: pixels.fill(0) @@ -99,7 +103,7 @@ while True: if now - start > ZOMBIE_TIME: print("Zombie code sent! \n") red_led.value = True - encoder.transmit(pulseout, [10, 10, 10, 10]) + encoder.transmit(pulseout, ZOMBIE_IR) red_led.value = False start = time.monotonic() elif mode is healer: @@ -112,6 +116,6 @@ while True: if now - start > HEALER_TIME: print("Healer code sent! \n") red_led.value = True - encoder.transmit(pulseout, [20, 20, 20, 20]) + encoder.transmit(pulseout, HEALER_IR) red_led.value = False start = time.monotonic()