I am writing an EV3 micropython program meant to test my remote, but it does not work. When I run it, I see no errors at all. Instead, I just see a "play" symbol and the program continuously runs. If I press any buttons on my remote control, nothing at all happens. The code is below:

#!/usr/bin/env pybricks-micropython
from pybricks.hubs import EV3Brick
from pybricks.ev3devices import (Motor, TouchSensor, ColorSensor,
                                 InfraredSensor, UltrasonicSensor, GyroSensor)
from pybricks.parameters import Port, Stop, Direction, Button, Color
from pybricks.tools import wait, StopWatch, DataLog
from pybricks.robotics import DriveBase
from pybricks.media.ev3dev import SoundFile, ImageFile

# This program requires LEGO EV3 MicroPython v2.0 or higher.
# Click "Open user guide" on the EV3 extension tab for more information.

# Create your objects here.
ev3 = EV3Brick()
ir = InfraredSensor(Port.S1)
while True:
    if ir.buttons(1) == Button.BEACON:

Do you have any solutions to this problem? Thanks.


You can get community support for Pybricks at https://github.com/pybricks/support.

ir.buttons(1) returns a list of pressed buttons, so in this particular program

if ir.buttons(1) == Button.BEACON:

needs to be changed to

 if Button.BEACON in ir.buttons(1):

This will test if item is in list.

  • 1
    Worked perfectly for me.Thank you! – technicguy1 Nov 3 '20 at 4:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.