After following the suggestions given to me, I sketched this:
#include <legopowerfunctions.h> // Lego PF Library
LEGOPowerFunctions lego(13); // Pin for Lego PF IR Output
//configure the obstacle avoiding sensor
int sensorEN = 7; // Common pin for module
int sensorLO = 6; // Left Object detected output pin
int sensorRO = 5; // Right Object detected output pin
int senValue = 0; // variable to store the value coming from the sensor
unsigned long last_event = 1;
void setup() {
last_event=millis();
// Set the desired pin modes
pinMode(sensorEN, OUTPUT);
pinMode(sensorLO, INPUT);
pinMode(sensorRO, INPUT);
// ready the sensor
digitalWrite(sensorEN, HIGH);
}
void loop()
{
// move forward
if ((digitalRead(sensorLO) == LOW) && (digitalRead(sensorRO) == LOW)) {
lego.ComboPWM(PWM_REV3, PWM_FWD3, CH4);
}
{
// move left
if ((digitalRead(sensorLO) == HIGH) && (digitalRead(sensorRO) == LOW)) {
lego.ComboPWM(PWM_BRK, PWM_FWD3, CH4);
}
{
// move right
if ((digitalRead(sensorLO) == LOW) && (digitalRead(sensorRO) == HIGH)) {
lego.ComboPWM(PWM_REV3, PWM_BRK, CH4);
}
{
// move backwards
if ((digitalRead(sensorLO) == HIGH) && (digitalRead(sensorRO) == HIGH)) {
lego.ComboPWM(PWM_FWD3, PWM_REV3, CH4);
}
}
}
}
}
After uploading the code I put my robot on the floor and it started roaming.. and it worked!!!

Totally awesome! Throughout the years I tried several times to build and programme something like this,
so for me it is a big breakthrough! :-) So many thanks for the nice people on this forum, people who write
tutorials and the Arduino team for developing a great platform!
Ofcourse I have some questions left, about the sketch, like:
- Is this sketch memory friendly?
Because I see this roaming sketch as a first chapter, I do want to add more functionality, like using RGB LEDS
for Head, Tail and turninglights, some sound events.
M