Model Railroad System  2.2.2
Model RR signals with an Arduino
Macros | Functions | Variables
Ardunio Signal Driver using a MAX72XX

This is the software downloaded to the Ardunio to interface to the MAX72XX LED multiplexer driving the signals. More...

Macros

#define R_R   B00001001
 Red over Red (Stop) More...
 
#define R_Y   B00001010
 Red over Yellow (Approach Limited) More...
 
#define R_G   B00001100
 Red over Green (Slow Clear) More...
 
#define Y_R   B00010001
 Yellow over Red (Approach) More...
 
#define G_R   B00100001
 Green over red (Clear) More...
 
#define DARK   B00000000
 Dark (all lights off) More...
 

Functions

void setup ()
 The setup function initializes the MAX72xx chip and sends an announcement to the host computer over the serial port. More...
 
int GetAspectBits (const char *aspectname)
 Test for each signal aspect string and when a match Occurs, return the corresponding bit pattern. More...
 
void loop ()
 The main loop function. More...
 

Variables

LedControl lc1 =LedControl(12,11,10,1)
 Create a new LedControl. More...
 
int s_digit
 Start digit. More...
 
int e_digit
 End digit. More...
 
int i_digit
 Current digit. More...
 
int i_bits
 Current bits. More...
 
boolean test = false
 Flag indicating if we are in test mode. More...
 

Detailed Description

This is the software downloaded to the Ardunio to interface to the MAX72XX LED multiplexer driving the signals.

Macro Definition Documentation

◆ DARK

#define DARK   B00000000

Dark (all lights off)

Definition at line 68 of file SignalDriverMax72xx.ino.

◆ G_R

#define G_R   B00100001

Green over red (Clear)

Definition at line 66 of file SignalDriverMax72xx.ino.

◆ R_G

#define R_G   B00001100

Red over Green (Slow Clear)

Definition at line 62 of file SignalDriverMax72xx.ino.

◆ R_R

#define R_R   B00001001

Red over Red (Stop)

Definition at line 58 of file SignalDriverMax72xx.ino.

◆ R_Y

#define R_Y   B00001010

Red over Yellow (Approach Limited)

Definition at line 60 of file SignalDriverMax72xx.ino.

◆ Y_R

#define Y_R   B00010001

Yellow over Red (Approach)

Definition at line 64 of file SignalDriverMax72xx.ino.

Function Documentation

◆ GetAspectBits()

int GetAspectBits ( const char *  aspectname)

Test for each signal aspect string and when a match Occurs, return the corresponding bit pattern.

Parameters
aspectnameThe aspect text sent from the host.
Returns
The bit pattern to display the selected aspect.

Definition at line 75 of file SignalDriverMax72xx.ino.

◆ loop()

void loop ( )

The main loop function.

Here we read a one line command from the host computer and decide what to do. There are only three commands defined:

  • One to turn all of the LEDs off.
  • One to set the aspect of one signal.
  • And one to initiate a test sequence.

Definition at line 92 of file SignalDriverMax72xx.ino.

◆ setup()

void setup ( )

The setup function initializes the MAX72xx chip and sends an announcement to the host computer over the serial port.

Definition at line 41 of file SignalDriverMax72xx.ino.

Variable Documentation

◆ e_digit

int e_digit

End digit.

Definition at line 29 of file SignalDriverMax72xx.ino.

◆ i_bits

int i_bits

Current bits.

Definition at line 33 of file SignalDriverMax72xx.ino.

◆ i_digit

int i_digit

Current digit.

Definition at line 31 of file SignalDriverMax72xx.ino.

◆ lc1

LedControl lc1 =LedControl(12,11,10,1)

Create a new LedControl.

We use pins 12,11 and 10 for the SPI interface With our hardware we have connected pin 12 to the DATA IN-pin (1) of the first MAX7221 pin 11 is connected to the CLK-pin(13) of the first MAX7221 pin 10 is connected to the LOAD-pin(12) of the first MAX7221
We will only have a single MAX7221 attached to the arduino

Definition at line 20 of file SignalDriverMax72xx.ino.

◆ s_digit

int s_digit

Start digit.

Definition at line 27 of file SignalDriverMax72xx.ino.

◆ test

boolean test = false

Flag indicating if we are in test mode.

Definition at line 35 of file SignalDriverMax72xx.ino.