def METHOD_NAME():
  global oldbutt
  global pin
  buf = file.read(3)
  pin = pin & 0x07
  button = ord( buf[0] ) & pin # mask out just the required button(s)
  if button != oldbutt:  # only send if changed
      oldbutt = button
      print(button)