Arduino-LPF: Lego Power Functions IR receiver with LCD

A basic demonstration of an Arduino Uno with with an TSOP38238 IR receiver and a LCD acting as a Lego Power Functions IR receiver:

The setup is pretty simple:

Arduino-LPF

And the code using Arduino-LPF library is also pretty simple:

//LPF stuff
#include "Arduino-LPF-receiver.h"
#include "Arduino-LPF-driver.h"

//LCD stuff
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

//LPF stuff
const byte IRreceiverPin = 2;
byte       address     = 0; //is always 0 in normal Power Functions
byte       channel     = 0; //between 0 and 3 (for channel 1-4)
LPFDriver driver( address, channel );

//LCD stuff
LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

void control_motor( int8_t speed0, byte brake0, int8_t speed1, byte brake1 ) {
  lcd.setCursor(0,0);
  lcd.print( "Red  speed: " );
  lcd.print( speed0 );
  lcd.print( "   " );
  lcd.setCursor(0,1);
  lcd.print( "Blue speed: " );
  lcd.print( speed1 );
  lcd.print( "   " );
}

void setup() {
  //LPF stuff
  pinMode(IRreceiverPin, INPUT);
  lpf_receiver_set_pin(IRreceiverPin);
  attachInterrupt(digitalPinToInterrupt(IRreceiverPin), lpf_receiver_interrupt, CHANGE);
  driver.set_driverfunction( control_motor );

  //LCD stuff
  lcd.begin(16,2);
  lcd.backlight();
}

void loop() {
  //LPF stuff  
  while( lpf_msg msg = lpf_receiver_get_next_msg() ) {
    driver.parse_msg(msg);
  }
}