setTimeout not working with functions containing variables

Thank you very much, PierreND! That has vorked perfectly.
Also thank you Robert Nix. I could summarize the function calls as you propsed.
Sorry for the late reply, but I had trouble flashing my BBB and had to wait for a new microSD card.

The whole code shrinked now to a few lines:
var b = require(‘bonescript’);

var red = “P8_13”;
var yellow = “P8_15”;
var green = “P8_17”;

b.pinMode(red, b.OUTPUT);
b.pinMode(yellow, b.OUTPUT);
b.pinMode(green, b.OUTPUT);

var r = 1000;
var y = 300;
var g = 1000;
var on = b.HIGH;
var off = b.LOW;

LED(red, on);
setTimeout(function() {LED(yellow, on);}, r);
setTimeout(function() {LED(red, off); LED(yellow, off); LED(green, on);}, r+y);
setTimeout(function() {LED(green, off); LED(yellow, on);}, r+y+g);
setTimeout(function() {LED(yellow, off); LED(red, on);}, r+y+g+y);

function LED(xPin, xState){
b.digitalWrite(xPin, xState)};