Sketch for model train block signals issues

Ok, first things first - I am new here. This is my first post (WAY TOO LONG, I know). I am new to arduino and C++. I was pretty good at BASIC (old guy). I really do try and work things out myself, before asking for help (not always the best option).
I DID read thru the excellent writings of Robin2 "SeveralThingsAtTheSameTime" and UKHeliBob's "Using millis()...". Actually I read them more than a few times. I also read other articles concerning using millis() for timing......So oh wonderful teachers............I did my homework but still need help (this aging thing can be sooo annoying). As one poster mentioned - I guess I AM having difficulty wrapping my head around this concept.

This sketch will be used for two model train lines running parallel. Trains run both directions. Each set of signals should operate independently of each other - eventually, there will be an interchange crossing between the two lines, so they will be integrated after I get the sketch below working correctly.

What I am trying to do:

  • set up block signals for a model railroad. These signals are activated by an IR detection sensor embedded in the tracks. For each sensor there is a set of signal lights (RED, YELLOW, GREEN). There is a set of sensors and signals for each direction of travel (left or right). I am only trying to change the light sequence when a train activates a sensor, not stop the trains. I have two parallel tracks that I am putting signals on. Each track currently operates independently of each other. I know I can use a separate Arduino for each track, but am trying to combine the process in one Arduino, because there will eventually be an interchange crossing between the two tracks, requiring the signals to work together.
    The attached code works for the two sets of parallel track I am using. Sensors cause the signal lights to change correctly.
    What I am having trouble with:
  1. When one set of sensors is activated, the other set will not activate (why I am trying to use millis() to "do two things at once") until the first sequence is complete.
  2. I cannot get a "delay" of 5 seconds after the sequence goes to "YELLOW".

I included a description at the top of the sketch.
Any assistance would be greatly appreciated. Ben

/* This sketch will be used for two model train lines running
 *  parallel. Trains run both directions. Each set of signals 
 *  should operate independently of each other - eventually,
 *  there will be an interchange crossing between the two lines,
 *  so they will be integrated after I get the skecth below 
 *  working correctly.
 * 
 *  Setup is two sets of IR detection sensors that each set
 *  triggers GREEN,RED,YELLOW lights - depending on which 
 *  sensor is activated first.
 *  The valA1, valA2, etc. are reading the values of each sensor
 *  and the value is what triggers the "if" statements. These Sensors 
 *  usually are outputing a number in the 900's when 
 *  not activated, and in the low 100's when activated.
 *  GREEN is default ON state (sensors are common anode,
 *  hence HIGH is off)
 *  working example: if Left sensor activated, 
 *  RED turns on, GREEN off. RED stays on as long as 
 *  Left sensor is activated
 *  Once Right sensor is activated, and left is sensor is
 *  deactivated, YELLOW turns on, RED off
 *  Once both sensors are deactivated, there should be
 *  a 5 second delay, then GREEN goes on
 *  
 *  this currently works for both sets of sensors but 
 *  only one is triggered at a time, and
 *  there is no "delay" between yellow and back to green.
 *  I want a 5 second delay between light going from YELLOW
 *  back to GREEN.

*/

int sensePin1 = A0;
int sensePin2 = A1;
int RED = 6;
int YELLOW = 5;
int GREEN = 3;
int sensePin3 = A2;
int sensePin4 = A3;
int RED4 = 14;
int YELLOW4 = 15;
int GREEN4 = 16;
int POWER = 8;

unsigned long currentMillis = 0;
unsigned long previousMillis = 0;
const int interval = 5000;

void setup() {
  Serial.begin(9600);
  pinMode(RED, OUTPUT);
  pinMode(YELLOW, OUTPUT);
  pinMode(GREEN, OUTPUT);
  pinMode(POWER, OUTPUT);
  pinMode(RED4, OUTPUT);
  pinMode(YELLOW4, OUTPUT);
  pinMode(GREEN4, OUTPUT);
  pinMode(POWER, OUTPUT);
}
enum SIGNALSTATES
{
  ST_GREEN,
  ST_RED1,
  ST_RED2,
  ST_YELLOW,
  ST_GREEN4,
  ST_RED4,
  ST_RED4a,
  ST_YELLOW4
};

SIGNALSTATES signalState = ST_GREEN;


void loop() {

  currentMillis = millis();

  int valA1 = analogRead(sensePin1);
  int valA2 = analogRead(sensePin2);
  int valA3 = analogRead(sensePin3);
  int valA4 = analogRead(sensePin4);
  Serial.println(valA1);
  Serial.println(valA2);
  Serial.println(valA3);
  Serial.println(valA4);


  switch (signalState)
  {
    case ST_GREEN:
      signalgreen(valA1, valA2, valA3, valA4);
      break;
    case ST_RED1:
      signalred1(valA1, valA2);
      break;
    case ST_RED2:
      signalred2(valA1, valA2);
      break;
    case ST_YELLOW:
      signalyellow(valA1, valA2);
      break;
    case ST_GREEN4:
      signalgreen4(valA3, valA4);
      break;
    case ST_RED4:
      signalred4(valA3, valA4);
      break;
    case ST_RED4a:
      signalred4a(valA3, valA4);
      break;
    case ST_YELLOW4:
      signalyellow4(valA3, valA4);
      break;
  }
}


void signalgreen(int valA1, int valA2, int valA3, int valA4) {
  digitalWrite(GREEN, LOW);
  digitalWrite(RED, HIGH);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(POWER, HIGH);
  digitalWrite(RED4, HIGH);
  digitalWrite(GREEN4, LOW);
  digitalWrite(YELLOW4, HIGH);

  if (valA1 < 500 && valA2 > 500) {
    signalState = ST_RED1;
  }
  else if (valA1 > 500 && valA2 < 500) {
    signalState = ST_RED2;
  }
  if (valA3 < 500 && valA4 > 500) {
    signalState = ST_RED4;
  }
  else if (valA3 > 500 && valA4 < 500) {
    signalState = ST_RED4a;
  }
}

void signalred1(int valA1, int valA2) {
  digitalWrite(GREEN, HIGH);
  digitalWrite(RED, LOW);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(POWER, HIGH);

  if (valA1 > 500 && valA2 < 500) {
    signalState = ST_YELLOW;
  }
}

void signalred2(int valA1, int valA2) {
  digitalWrite(GREEN, HIGH);
  digitalWrite(RED, LOW);
  digitalWrite(YELLOW, HIGH);
  digitalWrite(POWER, HIGH);

  if (valA1 < 500 && valA2 > 500) {
    signalState = ST_YELLOW;
  }
}

void signalyellow(int valA1, int valA2) {

  digitalWrite(GREEN, HIGH);
  digitalWrite(RED, HIGH);
  digitalWrite(YELLOW, LOW);
  digitalWrite(POWER, HIGH);

  if (valA1 > 500 && valA2 > 500) {
    if (currentMillis - previousMillis >= interval)
      signalState = ST_GREEN;

    previousMillis += currentMillis;
  }
}
void signalgreen4(int valA3, int valA4) {
  digitalWrite(GREEN4, LOW);
  digitalWrite(RED4, HIGH);
  digitalWrite(YELLOW4, HIGH);
  digitalWrite(POWER, HIGH);

  if (valA3 < 500 && valA4 > 500) {
    signalState = ST_RED4;
  }
  else if (valA3 > 500 && valA4 < 500) {
    signalState = ST_RED4a;
  }
}

void signalred4(int valA3, int valA4) {
  digitalWrite(GREEN4, HIGH);
  digitalWrite(RED4, LOW);
  digitalWrite(YELLOW4, HIGH);
  digitalWrite(POWER, HIGH);

  if (valA3 > 500 && valA4 < 500) {
    signalState = ST_YELLOW4;
  }
}

void signalred4a(int valA3, int valA4) {
  digitalWrite(GREEN4, HIGH);
  digitalWrite(RED4, LOW);
  digitalWrite(YELLOW4, HIGH);
  digitalWrite(POWER, HIGH);

  if (valA3 < 500 && valA4 > 500) {
    signalState = ST_YELLOW4;
  }
}

void signalyellow4(int valA3, int valA4) {

  digitalWrite(GREEN4, HIGH);
  digitalWrite(RED4, HIGH);
  digitalWrite(YELLOW4, LOW);
  digitalWrite(POWER, HIGH);

  if (valA3 > 500 && valA4 > 500) {
    if (currentMillis - previousMillis >= interval)
      signalState = ST_GREEN;

    previousMillis += currentMillis;
  }
}

First off, welcome to the Forum. Contrary to popular belief, we do not feed people to the lions here.

More (or equal) importantly, what you are trying to do is easily accomplished. Try thinking of what your are doing as a single event which will operate based on input from one of two sensors. Use a pair of flags to differentiate between which sensor you happen to be servicing at the time. When an event occurs, train passing a sensor, reset your timer (currentMillis = millis() effectively sets currentMillis to zero) and set your state to the first of three. At each pass through the loop, test within that state the elapsed time ( millis() - currentMillis > elapsed time), if the condition is true, increment the state and reset the timer for the next state.

You can use two state variables, one for each event, and test each separately.

Your code would look something like this:

void loop()

  sensor1_triggered && !sensor1_flag?
    set sensor1_flag
    currentMillis1 = millis
    state1 = state1_1
  sensor2_triggered && !sensor2_flag?
    set sensor2_flag
    currentMillis2 = millis
    state2 = state2_1

  if sensor1
    switch (state1)
      do state1_1 lamp stuff
      test state1_1 elapsed_time
        if time_has_has_elapsed
          reset timer for state1_2
          change to state1_2

Repeat the switch cases for state1_2 and state1_3, repeating the whole 'if sensor' test for sensor2.

At the end or the final state in each instance, make your 4th state an idle state and reset the sensor1/2_flag. This flag is used in the initial test to ensure that no state condition (from idle) gets entered until the sensor gets triggered, and once triggered, is then ignored do you don't re-initialize.

I'm not clear if you want to create a signalling system for bi-directional running on both tracks or if you want to have separate UP and DOWN lines?

Consequently I am not clear is the 6 signals in your ENUM are for one line or for both lines.

In any case I think each set of 3 signals has to be treated separately because one light of both sets must always be ON.

I can't help feeling that the logic would be easier to understand if you used more meaningful names than GREEN and GREEN4 for example. For bi directional running I think I would call them OuterDownGreen and OuterUpGreen where I use the word "Outer" to distinguish between the two tracks. The other track would have InnerUpGreen and InnerDownGreen.

(In the UK they use UP and DOWN to indicate the direction so if you aren't modelling a UK railway some other term may be appropriate).

I also think it would be useful to write down (pencil and paper, or text editor) a complete set of signal conditions before you consider how to write a program to implement it.

I was going to suggest some logic but then I realized I do not sufficiently understand what you want to happen.

...R

Thanks Robin2. I understand your confusion and will try to give more info.

The two lines are bi-directional. In the US, they are often Westbound-Eastbound, etc. I am currently using LEFT-RIGHT.
The two lines are actually MAINLINE and BRANCHLINE. I do plan on cleaning up the code to make it more understandable.....

The 6 signals are actually 3 for each line (RED-YELLOW-GREEN is one line) and (RED4-YELLOW4-GREEN4) are the second line in this sketch. Each sensor will actually have its own set of 3 lights per signal, which will increase the number of lights to 12 lights (4 sets of RED-YELLOW-GREEN). I left out the extra sets to simplify the code for testing. Once the code works as I want, I should be able to add in the additional lights without too much difficulty.

I have attached a diagram with explanation that will hopefully clear up some confusion - I did write down all signal conditions and mapped them out before beginning the code process (used up a few notepads). The majority of this code came from someone else which I have adapted for my needs.
As I stated earlier, the sensors and lights work as desired for each track. The 2 issues I am having are adding a "delay" when switching signal states and when one track sensor is activated, the other track sensors cannot be activated. Thank you for your assistance. Ben

Signal States.doc (92 KB)

Thank you DKWatson. I will take your words of wisdom and delve further into the fray......
I posted a bit more info and diagram to explain what I am trying to do better per Robin@'s suggestions. Ben

Not sure how American systems work, but you have only one signal for both directions? Do you turn them around depending on the direction of the train? 8)

What you're describing does not seem to be a block system but this does make it clear

Below the contents of your doc; not everybody does word documents.

Ascii art of image

    left branch             branch signal       right branch
    sensor                                      sensor
    sensepin 1                                  sensepin 2

    ==============================================================      branch
    
    ==============================================================      main
    
    left main               main   signal       right main
    sensor                                      sensor
    sensepin 3                                  sensepin 4

Text

Default State (ST_GREEN) for both tracks
Both GREEN lights only on, no sensors activated

There can be one train running on each track at the same time, activating the appropriate signals, but independent of each other (ie. Train coming on LeftBranch and LeftMain at the same time).

Train coming on LeftBranch
SensePin1 only activated (switch signalState to ST_RED1)
RED light on, YELLOW and GREEN light off (light on MainLine should not change)
When front of train activates SensePin2 (rest of train still passing over SensePin1), switch signalState to ST_YELLOW
YELLOW light on, RED and GREEN light off
When train has passed both sensors, WAIT 5 seconds, and switch back to ST_GREEN
GREEN light only on
Reverse functionality if train is coming on RightBranch

Same functionality should occur on MainLine, and independent of BranchLine

Thanks sterretje.I am learning as I go. My example only contains one signal per track for simplicity.after I can get this to work I will be adding an additional signal per track with a signal set in each direction...no need to turn the signals.

Some comments on your current code; I might be misunderstanding it though.

Although you say that it works, I think that you have a problem with lines like

previousMillis += currentMillis;

That will increment your previousMillis with the currentTime; if currentTime is e.g 100,000, it will increment by 100,000. Maybe you meant to use

previousMillis = currentMillis;

You also seem to do that not based on the result of

if (currentMillis - previousMillis >= interval)

Maybe your missing some {} for that if.

// edit
What does your sensor read when it detects a train? A low value or a high value?

This is how I would translate your requirement

Train coming on LeftBranch
SensePin1 only activated (switch signalState to ST_RED1)
RED light on, YELLOW and GREEN light off (light on MainLine should not change)
When front of train activates SensePin2 (rest of train still passing over SensePin1), switch signalState to ST_YELLOW
YELLOW light on, RED and GREEN light off
When train has passed both sensors, WAIT 5 seconds, and switch back to ST_GREEN

Into a sequence that I could convert tot code

All lights green
TrainState = NoTrain
Train coming from left
BranchLeftPin triggered and BranchRightPin clear and TrainState == NoTrain
 TrainState = LeftTrainArrived
 LeftRed ON
BranchLeftPin triggered BranchRightPin triggered and TrainState == LeftTrainArrived
 TrainState = LeftTrainPassing
 LeftYellow ON
BranchLeftPin clear BranchRightPin clear and TrainState == LeftTrainPassing
 startTimer
TimerExpired and TrainState == LeftTrainPassing
 LeftGreen ON
 TrainState = NoTrain

I have included the word Left so you could write a similar sequence for RightTrainArrived etc. Looking forward to the time when you install a junction maybe it should be BranchLeftTrain... and BranchRightTrain...

You can create an ENUM to implement the names for the states

(Obviously not tested)

...R

You will probably end with a big complicated code if you continue on the same 'track' :wink:

I would start by putting all relevant information for a signal together in e.g. a struct or class. I'm more a C person, so will use a struct. A struct is like a definition of a record in a phone book that combines a name with a phone number.

In your case, there are a few variables that can go in the struct; the pins and the state. For the state, we use an enum similar to what you use, but limited to just one signal.

// signal states
enum SIGNALSTATE
{
  RED,       // signal shows red
  YELLOW,    // signal shows yellow
  GREEN,     // not implemented
};

struct SIGNAL
{
  const byte pinRed;
  const byte pinYellow;
  const byte pinGreen;

  SIGNALSTATE state;
};

You can now populate an array of signals; the below contains two signals (pin numbers based on your original code) I've set the initial state to green

SIGNAL signals[] =
{
  {6, 5, 3, GREEN},
  {14, 15, 16, GREEN},
};

In setup, you now can set the pinModes for the signal pins in the following way. To be able to determine how many signals there are, we use a so-called macro; place the below at the top of your code

#define NUMELEMENTS(x) (sizeof(x) / sizeof(x[0]))

sizeof(x) gives you the total number of bytes that x uses, sizeof(x[0]) gives you the number of bytes that one element in the array uses; dividing gives you the number oof elements.

In setup

void setup()
{
  for(uint16_t cnt=0;cnt<NUMELEMENTS(signals);cnt++)
  {
    pinMode(signals[cnt].pinRed, OUTPUT);
    pinMode(signals[cnt].pinYellow, OUTPUT);
    pinMode(signals[cnt].pinGreen, OUTPUT);
  }
}

The above loops through the signals array and for each array element sets the 3 pins to output; note the use of the dot.

Next you can write a function to control a specified signal

/*
  set signal color
  In
    signal whose colour to set
 */
void setSignal(SIGNAL signal)
{
  // all leds off
  digitalWrite(signal.pinRed, LOW);
  digitalWrite(signal.pinYellow, LOW);
  digitalWrite(signal.pinGreen, LOW);

  // switch correct led on
  switch (signal.state)
  {
    case GREEN:
      digitalWrite(signal.pinGreen, HIGH);
      Serial.println("green");
      break;
    case RED:
      digitalWrite(signal.pinRed, HIGH);
      Serial.println("red");
      break;
    case YELLOW:
      digitalWrite(signal.pinYellow, HIGH);
      Serial.println("yellow");
      break;
  }
}

The above function takes a signal as its argument and does its 'thing' based on the state of the signal.

Now in loop, you can set the colour of a signal. To make the code easier to read, add the below at the top of the code

// signal array index
#define MAINSIGNAL 0
#define BRANCHSIGNAL 1

And this will be a demo loop

void loop()
{
  // determine the signal colours based on your inputs
  signals[MAINSIGNAL].state = GREEN;
  signals[BRANCHSIGNAL].state = YELLOW;

  // update all signals
  for (uint16_t cnt = 0; cnt < NUMELEMENTS(signals); cnt++)
  {
    setSignal(signals[cnt]);
  }

  // wait forever as this is a demo
  for (;;);
}

Full code

#define NUMELEMENTS(x) (sizeof(x) / sizeof(x[0]))

// signal array index
#define MAINSIGNAL 0
#define BRANCHSIGNAL 1


// signal states
enum SIGNALSTATE
{
  RED,       // signal shows red
  YELLOW,    // signal shows yellow
  GREEN,     // not implemented
};

struct SIGNAL
{
  const byte pinRed;
  const byte pinYellow;
  const byte pinGreen;

  SIGNALSTATE state;
};

SIGNAL signals[] =
{
  {6, 5, 3, RED},
  {14, 15, 16, RED},
};

void setup()
{
  // setup serial comms
  Serial.begin(57600);
  while (!Serial);


  // set signal pins pinMode
  for (uint16_t cnt = 0; cnt < NUMELEMENTS(signals); cnt++)
  {
    pinMode(signals[cnt].pinRed, OUTPUT);
    pinMode(signals[cnt].pinYellow, OUTPUT);
    pinMode(signals[cnt].pinGreen, OUTPUT);
  }

  // set signals to initial state
  // update all signals
  for (uint16_t cnt = 0; cnt < NUMELEMENTS(signals); cnt++)
  {
    setSignal(signals[cnt]);
  }
}

void loop()
{
  // determine the signal colours based on your inputs
  signals[MAINSIGNAL].state = GREEN;
  signals[BRANCHSIGNAL].state = YELLOW;

  // update all signals
  for (uint16_t cnt = 0; cnt < NUMELEMENTS(signals); cnt++)
  {
    setSignal(signals[cnt]);
  }

  // wait forever
  for (;;);
}

/*
  set signal color
  In
    signal whose colour to set
*/
void setSignal(SIGNAL signal)
{
  // all leds off
  digitalWrite(signal.pinRed, LOW);
  digitalWrite(signal.pinYellow, LOW);
  digitalWrite(signal.pinGreen, LOW);

  // switch correct led on
  switch (signal.state)
  {
    case GREEN:
      digitalWrite(signal.pinGreen, HIGH);
      Serial.println("green");
      break;
    case RED:
      digitalWrite(signal.pinRed, HIGH);
      Serial.println("red");
      break;
    case YELLOW:
      digitalWrite(signal.pinYellow, HIGH);
      Serial.println("yellow");
      break;
  }
}

I suggest that you write a function that takes a sensor pin number as its input and returns LOW (0) or HIGH (1) depending on the sensor state. It will probably cleanup your code and will definitely make it more readable.

e.g.

/*
  get the state of a sensor
  In
    sensor pin number
  Returns
    LOW if sensor is blocked, else HIGH
*/
byte getSensorState(byte pinNumber)
{
  int val = analogRead(pinNumber);
  if (val < 300)
  {
    return LOW;
  }
  else
  {
    return HIGH;
  }
}

And use that function in loop().
you might want to / have to swap HIGH and LOW
Note:
for the last function

sterretje:
You will probably end with a big complicated code if you continue on the same 'track' :wink:

There is a lot of value in your Post but, thinking from a model railway point of view I am not convinced that this approach makes sense

 switch (signal.state)
  {
    case GREEN:
      digitalWrite(signal.pinGreen, HIGH);
      Serial.println("green");
      break;
    case RED:
      digitalWrite(signal.pinRed, HIGH);
      Serial.println("red");
      break;
    case YELLOW:
      digitalWrite(signal.pinYellow, HIGH);
      Serial.println("yellow");
      break;
  }

Rather than setting the signals based on a colour CASE I think they should be set based on a trainState CASE

Following from the style of my Reply #8 it might be like this

 switch (trainState)
  {
    case NoTrain:
      digitalWrite(signal.pinGreen, HIGH);
      Serial.println("green");
      break;
    case TrainArrived:
      digitalWrite(signal.pinRed, HIGH);
      Serial.println("red");
      break;
    case TrainPassing:
      digitalWrite(signal.pinYellow, HIGH);
      Serial.println("yellow");
      break;
  }

...R

My original code had

enum BLOCKSTATE
{
  OCCUPIED,
  EXPECT_STOP,
  EXPECT_TURN,
  FREE,
};

For simplicity, I decided to to change it to RED, YELLOW and GREEN (and leave EXPECT_TURN out)

That was however for a more complete solution with real blocks.

sterretje:
My original code had

enum BLOCKSTATE

{
  OCCUPIED,
  EXPECT_STOP,
  EXPECT_TURN,
  FREE,
};

I can understand Occupied and Free, but what do the others signify?

And, somewhat separately, I don't think the OP is trying to implement a block system. At first I thought he was and that was partly what confused me. I believe all he wants to happen is that the signals give the appearance of a block system - hence my state names. But I may be wrong :slight_smile:

...R

In the Dutch system, each block has RYG at its entrance.

If the signal for block N is showing red (because N+1 is occupied), the signal N-1 will show yellow to indicate that the driver can expect red at the next signal.

EXPECT_TURN comes from the German system which works differently. The have a (literally translated) pre-signal (e.g. halfway the block) to indicate what the next main signal will show. EXPECT_TURN is used to indicate that the train will change tracks (at a turnout / point, not sure what the correct English name is).

This is from memory, last time I looked into it was nearly 20 years ago.

sterretje:
EXPECT_TURN comes from the German system which works differently. The have a (literally translated) pre-signal (e.g. halfway the block) to indicate what the next main signal will show. EXPECT_TURN is used to indicate that the train will change tracks (at a turnout / point, not sure what the correct English name is).

AFAIK in the UK system there is a supplementary light (usually an angled line made up of a series of small white lamps) to indicate that the turnout is set for diversion to another track. However it is only at the signal close to the turnout so it does not give much advance warning.

...R

I just checked the German system; the enum value should actually be EXPECT_SLOW which is more universal. Not necessarily turn.

You can search for VR 0, VR 1 and VR 2 (note the spaces).

Is Expect Slow the equivalent of the the Yellow light in the UK - meaning that the next signal is Red?

Or maybe it is equivalent to the double yellow in the UK which means that the next signal is yellow and the one after that is red. This is used where trains operate at higher speeds.

Strictly speaking the system proposed by the OP is incorrect. His signal should stay at Red until the train has cleared the following signal and it should then change to Yellow and stay like that until the train has cleared the 3rd signal. However most model railways don't have long enough runs for that and I reckon the OP's system is reasonable if he just wants to mimic what a person standing beside the track and watching a signal would observe.

As I understand it the OP wants the signal to obey the train whereas on the real railway the train must obey the signal.

...R

EXPECT_STOP would be the equivalent for yellow indicating the next one is red.
EXPECT_SLOW indicates that there is a speed limitation indicated by the next signal. E.g. sharp curve, change track etc.

Thanks.

...R

. I believe all he wants to happen is that the signals give the appearance of a block system - hence my state names. But I may be wrong :slight_smile:

Robin2, you are correct in this. I am only trying to activate signals. I do not need to set up an actual block system for my layout. My layout is freelance and I do not follow exact prototypical standards - more general works for me.

To all - Information how other countries handle signaling is very interesting! There really is more than one way to do anything, for sure. Thank you for that.

Thank you all for your comments and suggestions. I am going to review them and revise my code based on all your suggestions..............but first ice cream and a nap............Ben