Multi-LED fixtures such as railroad crossings and stoplights can come in three styles:

Discrete (Both wires of each LED are brought out)
Common Anode (The “+” side or anodes of the LED’s are tied together and brought out as one wire)
Common Cathode (The “-” side or cathodes of the LED’s are tied together and brought out as one wire)

The Common Cathode type is treated differently, so a separate page is devoted to it. This page focuses on the other two. Since the Morsel includes “+” terminals, either discrete LED’s or Common Anode type can be connected directly to the green terminals.

Second Order Railroad Crossing

The old incandescent style railroad crossing light bulbs contain filaments that are so thick, they cool down more slowly than normal incandescent bulbs.  Thus they persist faintly for a longer time. The second order fade goes beyond a straight rate of fading and follows a curve instead. The first statement fades quickly to a fraction of full brightness. The second and third statements fade more slowly.

The crossing signal can be turned on and off from the CC pin with a switch (the switch should connect 5V to CC to turn off). Using Theme Designer, LED Ports used for other effects need not be affected by the CC pin.

// Railroad crossing
// with extra incandescent persistence

define segment1time 120ms
define segment2time 180ms
define segment3time 120ms
define turnOnTime 250ms
define halfTime 1s //time that one light turns on or off
define fullTime 2s //time that sequence ends

define topBrightness 100%
define upperSegmentBrightness 20%
define lowerSegmentBrightness 5%
define bottomBrightness 0%

//code starts here

        go to start2 with 50% chance //random starting point

@0ms    start1

        chn1 = fade from topBrightness to upperSegmentBrightness for segment1time //channel 1 off 2 on
        chn2 = fade from bottomBrightness to topBrightness for turnOnTime 
@+segment1time
        chn1 = fade from upperSegmentBrightness to lowerSegmentBrightness for segment2time 
@+segment2time 
        chn1 = fade from lowerSegmentBrightness to bottomBrightness for segment3time

@halfTime start2

        chn2 = fade from topBrightness to upperSegmentBrightness for segment1time 
        chn1 = fade from bottomBrightness to topBrightness for turnOnTime 
@+segment1time 
        chn2 = fade from upperSegmentBrightness to lowerSegmentBrightness for segment2time 
@+segment2time 
        chn2 = fade from lowerSegmentBrightness to bottomBrightness for segment3time

@fullTime

        //add slight randomness to repeat rate
        go to skipSlip with 50% chance
@+50ms
skipSlip

        go to start1 // repeats

Stoplight and Synchronized Stoplights (2 sequences)

The Stoplight emulates a module sold by other suppliers, except this one has some extra features. It can emulate either LED or incandescent lights, the times are adjustable and of course any free LED Ports can be used for other purposes.

The Synchronized Stoplights can be placed at two to three street intersections in a row. The light cycle time may be adjusted. The relationships between blocks is fixed at 1/3 and 2/3 of the cycle. By swapping the order, lights can be 1/3 cycle apart or 2/3 cycle apart (one cycle is green-yellow-red. The next green begins another cycle).

Timing is slightly randomized to allow separate, independent stoplights instead of a long, synchronized street.

//2- or 4-way traffic light
//with green-yellow-red (G Y R) led's

//Use Theme Designer to bring out only the desired channels:
//for 2-way G Y R, use chn 1, 2, 3
//for 4-way G Y R, also use chn 4, 5, 6

//for multi-street synchronized lights:
//a) use random starting point skew (requires 1 custom memory for all streets)
// Sid Column of Theme Designer identifies different street corners 
//b)or use fixed starting skew (requires 1 custom memory per skew)
// Sequence name, custom1, etc. identifies different street corners
//With 9 channels available, one or all streets use 2-way (3 leds per street)

//traffic times adjustable

define yellowTime 2.5s
define greenTime 10s
define bothRedTime 1.5s
// red time is the sum of greenTime yellowTime and bothRedTime

//bulb type
//0ms for LED, 80-120ms for incandescent

define turnOnTime 100ms 
define turnOffTime 100ms

//making lights more readable
define greenLight chn1
define yellowLight chn2
define redLight chn3
define greenLight4way chn4
define yellowLight4way chn5
define redLight4way chn6


//code starts here


//uncomment for fixed starting skew (for the next street block)
//@+5s

//or uncomment for random starting point skew (changes each time it's powered up)
go between green and otherRedRed


        //set all lights in case random starting point used
green
        //2-way lights: Green
        greenLight = fade to 100% within turnOnTime
 
        yellowLight = fade to 0% within turnOffTime
        redLight = fade to 0% within turnOffTime

        //4-way lights: Red
        redLight4way = fade to 100% within turnOnTime
 
        yellowLight4way = fade to 0% within turnOffTime
        greenLight4way = fade to 0% within turnOffTime

@+greenTime

yellow
        //2-way lights: Yellow
        yellowLight = fade to 100% within turnOnTime
 
        greenLight = fade to 0% within turnOffTime
        redLight = fade to 0% within turnOffTime

        //4-way lights: Red
        redLight4way = fade to 100% within turnOnTime
 
        yellowLight4way = fade to 0% within turnOffTime
        greenLight4way = fade to 0% within turnOffTime

@+yellowTime

        redRed //both directions red for short time
        //2-way lights: Red
        redLight = fade to 100% within turnOnTime
 
        greenLIght = fade to 0% within turnOffTime
        yellowLight = fade to 0% within turnOffTime

        //4-way lights: Red
        redLight4way = fade to 100% within turnOnTime
 
        yellowLight4way = fade to 0% within turnOffTime
        greenLight4way = fade to 0% within turnOffTime

@+bothRedTime //4-way lights: Green

otherGreen
        //2-way lights: Red
        redLight = fade to 100% within turnOnTime

        greenLIght = fade to 0% within turnOffTime
        yellowLight = fade to 0% within turnOffTime

        //4-way lights: Green
        greenLight4way = fade to 100% within turnOnTime
 
        yellowLight4way = fade to 0% within turnOffTime
        redLight4way = fade to 0% within turnOffTime

@+greenTime

otherYellow
        //2-way lights: Red
        redLight = fade to 100% within turnOnTime

        greenLIght = fade to 0% within turnOffTime
        yellowLight = fade to 0% within turnOffTime

        //4-way lights: Yellow
        yellowLight4way = fade to 100% within turnOnTime
 
        greenLight4way = fade to 0% within turnOffTime
        redLight4way = fade to 0% within turnOffTime

@+yellowTime

otherRedRed
        //2-way lights: Red
        redLight = fade to 100% within turnOnTime
 
        greenLIght = fade to 0% within turnOffTime
        yellowLight = fade to 0% within turnOffTime

        //4-way lights: Red
        redLight4way = fade to 100% within turnOnTime
 
        yellowLight4way = fade to 0% within turnOffTime
        greenLight4way = fade to 0% within turnOffTime

@+bothRedTime

        //slight speed difference if more than one copy is running
        go to slightSlip with 50% chance
@+25ms  slightSlip

        //repeat
        go to green

 

Three Synchronized Traffic Lights.

//synchronized traffic lights
//three 2-way lights all on the same stretch of road
//with a time skew between them.
//To maximize action:
//Skew is such that only 1 light changes at a time
//and no other light changes when one is yellow
//three stoplights are depicted (with no 4-way intersection lights)
// Channel 
//           Grn Yel Red
// 1st block  1   2   3  main stoplight
// 2nd block  4   5   6  "skew" follows 1/3 cycle after main
// 3rd block  7   8   9  "skewskew" follows 2/3 cycle after main

//alternate order
// Channel 
//           Grn Yel Red
// 1st block  1   2   3  main stoplight, starts at 0/3 cycle
// 2nd block  7   8   9  "skewskew" follows 2/3 cycle after main
// 3rd block  4   5   6  "skew" follows 4/3 cycle (i.e., 1/3) after main

// The above ordering need not be rewired. May be reassigned using Theme Designer

// typical time setting (BTU=2s YELTU-2.5s):
// green 12s
// yellow 2.5s
// red 12s
// total 26.5s

// BTU: Basic Time Unit and YELTU Yellow Time Unit
// change BTU to change the overall speed of the stoplights

define BTU @+2s //adjust basic stoplight time, default @+2s
define YELTU @+2.5s //adjust yellow time or keep constant, default @+2.5s

// for more defines, see bottom of page.
        // code starts here

        //random starting point in the cycle. 
        go between lbl1 and lbl3 //labels found in red defines

lightCycle

        green
BTU BTU
        skewSkewYellow
YELTU
        skewSkewRed
BTU BTU
        skewGreen
BTU BTU 
        yellow
YELTU
        red
BTU BTU
        skewSkewGreen
BTU BTU
        skewYellow
YELTU
        skewRed


BTU BTU 
        //slight speed difference if more than one copy used
        go to slightSlip with 50% chance
@+20ms  slightSlip
        go to lightCycle
       //end of sequence

//defines follow

//For the following, bulb type = Incandescent ("within 100ms") or LED ("within 0ms")

define green chn1= fade to 100% within 100ms chn3 = fade to 0% within 100ms

define yellow chn2= fade to 100% within 100ms chn1 = fade to 0% within 100ms

define red lbl1 chn3= fade to 100% within 100ms chn2 = fade to 0% within 100ms

define skewGreen chn4= fade to 100% within 100ms chn6 = fade to 0% within 100ms

define skewYellow chn5= fade to 100% within 100ms chn4 = fade to 0% within 100ms

define skewRed lbl2 chn6= fade to 100% within 100ms chn5 = fade to 0% within 100ms

define skewSkewGreen chn7= fade to 100% within 100ms chn9 = fade to 0% within 100ms

define skewSkewYellow chn8= fade to 100% within 100ms chn7 = fade to 0% within 100ms

define skewSkewRed lbl3 chn9= fade to 100% within 100ms chn8 = fade to 0% within 100ms

 

 

 

 

Forward