GLOBAL SITE AUSTRALIAN SITE

Reading remote on an event not working | EdPy Programming | Forum

Please consider registering
guest

Log In Register

Register | Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Topic3
Reading remote on an event not working
December 29, 2016
8:32 am
TRex
New Member
Members
Forum Posts: 1
Member Since:
December 29, 2016
sp_UserOfflineSmall Offline

How do you figure out what remote button was pushed, when using the remote event handler?

I have the following program:

def remotePress():
  Ed.PlayBeep()
  rc = Ed.ReadRemote()

  if (rc == Ed.REMOTE_CODE_0):
    Ed.Drive(Ed.FORWARD, Ed.SPEED_1, 30)
  if (rc == Ed.REMOTE_CODE_2):
    Ed.Drive(Ed.SPIN_RIGHT, Ed.SPEED_1, 96)
  if (rc == Ed.REMOTE_CODE_3):
    Ed.Drive(Ed.SPIN_LEFT, Ed.SPEED_1, 96)

Ed.RegisterEventHandler(Ed.EVENT_REMOTE_CODE, “remotePress”)

while True:
  Ed.TimeWait(1, Ed.TIME_SECONDS)

When I press a button on the remote, I hear the beep, but my variable rc is equal to Ed.REMOTE_CODE_NONE, as can be shown by adding the following code:

def remotePress():
  Ed.PlayBeep()
  rc = Ed.ReadRemote()
  while (rc == Ed.REMOTE_CODE_NONE):
    rc = Ed.ReadRemote()

  if (rc == Ed.REMOTE_CODE_0):
  Ed.Drive(Ed.FORWARD, Ed.SPEED_1, 30)

This makes it work but you have to press the button twice.

The documentation states that:

Edison is constantly updating the remote control register, this function will read the register and may read a remote code from before the read function is called in your code.

But it seems like the internal event handler is clearing this register, so there’s no way to determine what remote code was received.

January 25, 2017
3:23 pm
Ben
Admin
Forum Posts: 179
Member Since:
August 24, 2015
sp_UserOfflineSmall Offline

Hi

Thanks for bringing this to our attention

I’ll pass it on to our developers

June 4, 2019
1:14 am
Eric
Member
Members
Forum Posts: 4
Member Since:
February 17, 2019
sp_UserOfflineSmall Offline

Mr. TRex. I was just writing a remote control program and ran into the same issue as you. I discovered that the problem has nothing to do with the register. The problem is that the barcodes for the setting the remote codes on this page https://meetedison.com/robot-activities/youre-a-robot-programmer/remote-control-barcodes/are wrong.yelledison

The correct barcodes:

1. remote code #0

2. remote code #1

3. remote code #4

4. remote code #5

5. Remote code #2

6. Remote code #3

7. Remote code #6

8. Remote code #7

I used your code to write this simple remote control program. Using a DVD universal remote, I set up arrow = 0, left arrow = 1, right arrow = 2, down arrow = 3, ok/select = 4. Feel free to use/reuse.

#——–Your code below———–

def remotePress():
    Ed.PlayBeep()
    rc = Ed.ReadRemote()

    if rc == Ed.REMOTE_CODE_0:
      Ed.Drive(Ed.FORWARD, Ed.SPEED_1, Ed.DISTANCE_UNLIMITED)
    elif rc == Ed.REMOTE_CODE_1:
      Ed.Drive(Ed.FORWARD_LEFT, Ed.SPEED_1, Ed.DISTANCE_UNLIMITED)

    elif rc == Ed.REMOTE_CODE_2:
      Ed.Drive(Ed.FORWARD_RIGHT, Ed.SPEED_1, Ed.DISTANCE_UNLIMITED)

    elif rc == Ed.REMOTE_CODE_3:
      Ed.Drive(Ed.BACKWARD, Ed.SPEED_1, Ed.DISTANCE_UNLIMITED)

    elif rc == Ed.REMOTE_CODE_4:
      Ed.Drive(Ed.STOP, Ed.SPEED_1, Ed.DISTANCE_UNLIMITED)

Ed.RegisterEventHandler(Ed.EVENT_REMOTE_CODE, “remotePress”)

while True:
    Ed.TimeWait(1, Ed.TIME_SECONDS)

  • Keep up with Edison

    Sign up for our newsletter to get all things Edison delivered straight to your inbox.

  • This field is for validation purposes and should be left unchanged.

Heads up

The Australian Federal Parliament has passed a law that extends goods and services tax (GST) to low value imports of physical goods imported by consumers from 1 July 2018.

This means that all customers purchasing Edison robots and accessories with an Australian shipping address must now pay GST. The GST will be automatically added to your purchase and show as a line item on your invoice.

We've detected that you are in Australia, so we wanted to let you know that we have changed your settings to view our Australian site, which displays GST inclusive pricing.

You can change back to the GLOBAL SITE at any time using the link in the top left of the page.

OK got it!    Take me to the GLOBAL SITE instead

Country

Pin It on Pinterest

Share This