This page contains links to pages on this site that contains examples of C++ features.
DCC_Probe: Project that uses C++ interrupts to extract the data/commands embedded in the DCC signals on a model train track.
DCC_Debug: Project that inherits the DCC_Probe Class. Prints out results of DCC_Probe in an English like format.
DCC_Loco_ Fn. Project inherits the DCC_Probe class to capture the Loco Function states from the DCC signal
DCC_NCE_Bus Project develops a Cpp Library to monitor the NCE Bus. A special feature is that the library includes handlers that will call code from the user/client.
LDR_Sensor_Class: Introduction to classes and creating a library in the Arduino environment. Creates a method train_over_sensor( ) that has a 1 second filter.
IR_Sensor_Class: As per LDR_Sensor_Class but uses IR Sensor.
LCD_1602_Class: Simple entry level to Cpp and inheritance. Inherits a professional library to develop a very simple class. Demonstrates overloading with multiple definitions of message( ) method.
LCD_ROM_Class: Introduction to classes and creating a library in the Arduino environment. Creates a method that reads patterns for a LCD display from ROM.
LCD_Init_Class: A class that inherits the LCD_ROM_Class and overloads the constructor.
LCD_Print_Class: Class that inherits LCD_Init_Class and adds write( ) methods to display on LCD.
LDR_Overload_Class: Overloads the LDR_Sensor_Class to give option of programming filter time.
NCE_Bus_Probe: Class/Library to interface with the NCE RS485 Bus. Illustrates creating links to provide callback into client code (*.ino file) when specified events occur.
Signals2_Class: Develops a Cpp class/library for a two-aspect railway signal.
Signal3_Class: As per Signals2_Class for a 3-aspect signal and includes further examples of overloading.
LDR_Signals3_Class This project develops a class/library that inherits LDR_Sensor_Class and Signals3_Class
LDR_Signals3_Array: Array of the class LDR_Signals3_Class.
Single_Track_Class: Program develops a class to control trains entering a single section of track.
IR_Single_Track_Class: Program develops a class using IR sensors to control trains entering a single section of track. Code inherits both the IR_Sensor_Class and Signals3_Class libraries.
Touch_Pad_Class: A simple example of taking a working C program and converting to a C++ Class/Library
LDR_Ser_Sig3_Ser_Class: Project uses serial input and output interfaces between LDR sensors and 3 aspect signals. Example of program inheriting multiple classes.
Track_Train_ESP_Class: Converts Track_Train_ESP to a Cpp class to hide implementation details.
Track_Train_ESP_WiFi: Sends Train Status to a smartphone via WiFi. Example of a program inheriting two relatively large classes.
LDR_ESP_WiFi_SSE: Project uses LDRs to monitor a train. The ESP8266 controls signals and uses SSE to update any change in status to a smart device. Example of class inheriting several classes.
WiFi_123 Uses C++ lambda function.
Example of a project that inherits many classes/libraries: Note many options possible but highest level uses default values
Lowest Level: LDR_Serial_Sensor_Class (serial, load, clock); Circuit wiring.
begin( ) - initialises pins as given in constructor
train_over_sensor (sen) method to return status of sensor of interest
Signal3_Serial_Class (serial, clock); circuit wiring
begin( ) No arguments - assumes external NOR gate to obtain Amber, Positive signals, 4 sets of signals
begin(ext) ext = 1 external gate, ext = 0 no external gate
begin(ext,pol) pol = 1 positive polarity, pol = 0 negative polarity.
begin(ext,pol,no_sigs) no_sigs Number of signals
signal_control(sig,dsp) sig = signal of interest. dsp = state (1/0). Delay times default to 5 seconds
signal_control(sig,dsp,redWait) set delay of red signal
signal_control(sig,dsp,redWait,amberWait) set delay of amber signal
Middle Level: LDR_Ser_Sig3_Ser_Class ( ); -default wiring
LDR_Ser_Sig3_Ser_Class (int ser_in, int load, int clk_in, int ser_out, int clk_out );
begin (int external, int polarity,int no_sigs); signal wiring
signal_control(sig,dsp); Signal and state - inheriated from Signals3_Serial_Class
train_over_sensor(sen); Sensor of interest
Top Level: LDR_ESP_NOW ; Example uses default wiring
begin( ) ; Uses default values
Note LDR_ESP_NOW lets middle level LDR_Ser_Sig3_Ser_Class control signals.
Coal_Basin_Buttons: Small program that develops a Cpp class to read the status of switches on model train layout. ("A" to "M") above
Coal Basin LEDs: Small program to develop a Cpp Class for signals that control the train routes "A" through 'M"
Coal Basin Servo: Program that controls servos on above layout. Generates an object of the commercial library Adafruit_PWMServoDriver. Uses a PCA9685 Servo Driver Board
Coal Basin Signals: Develops a Cpp class/library to set the signals at points 1 through 11.
Coal Basin Control: Project inherits all the above classes to control the model railway yard shown. ie reads buttons, acknowledges on LEDs, sets servos and signals.