Train lights
Trains include a variety of types of lights, for safety, illumination, and communicating train status. The most universal type of light is the headlight, which is included on the front of locomotives, and frequently on the rear as well. Other types of lights include classification lights, which indicate train direction and status, and ditch lights, which are a pair of lights positioned towards the bottom of a train to illuminate the tracks. History 

The earliest trains did not run at night, but the need for running trains at night soon became apparent. In the United States, early records of headlight usage date back to 1832: that year, Horatio Allen devised the first known locomotive headlight - though his "headlight" consisted of a burning pile of wood on a flatcar, followed by a giant reflector on a second flatcar, pushed by a locomotive. While this method of illumination was impractical, other experimentation continued. One early method was to hang a number of lanterns off the front of a locomotive. In 1892 Clement E. Stretton writing in The Locomotive Engine and Its Development claimed that the Stockton & Darlington Railway locomotive No.23 Wilberforce which was delivered in 1832 had a coal basket that acted as a head and tail lamp. In the later 1830s, the first proper train headlight was built by two mechanics in New York: a box made of sheet metal and incorporating a reflector. Mass production of locomotive headlights was started in 1838 in that state, and by 1850 they were a common sight on trains in the United States. By the dawn of the American Civil War, nearly every locomotive in the country was equipped with a headlight. Despite experiments and advances in headlight technology in the 1800s, the very idea of using headlights on trains was for a long time controversial. As late as 1886, a railroad official in the United States was quoted as saying "On a road engine the headlight is of no earthly use to the engineer; it obstructs his vision so that he cannot see his switch lights, and I think that every thinking engineer will come to the conclusion that he would rather run in the night without a lamp, than with it, as he can see better in the dark". Early headlights were fueled by oil, though kerosene-fueled headlights were developed as well in the 1850s. The discovery of electricity soon led to experiments with using it to power locomotive lights, with the first-known example, a battery operated light, being tested in Russia in 1874. In 1883, a railroad company in France also experimented with electrical lights, but the first example to go into production was designed by an American inventor in 1897. In 1915, the United States Congress passed a law mandating every train be equipped with an electric headlight, ending all debate about their utility. Twin-sealed beam headlights were also invented after the end of World War II, and they were designed in a way where two lightbulbs are installed in one headlamp. Despite the widespread use of locomotive headlights in North America, in the United Kingdom trains typically ran without true headlights at night. Types

Train headlights 

Trains in the United Kingdom have separate headlights for day and night usage. Classification lights 

Also known as marker lights, these are used to provide information on the type and status of a train. Traditionally, classification lights existed in three colors: white lights indicated an "extra" train (a train that is not scheduled but added due to demand), green lights were displayed on a regularly scheduled train that was being followed by additional sections (extra train(s)), and red lights indicated the rear of a train. In the 21st century, the first two types of classification lights are seldom used, but several railroad companies continue the use of red marker lights to indicate the rear of a train. This is particularly used when locomotives are pushing a train from the rear - seeing red marker lights indicates that the train is moving away from the viewer, not towards them. Emergency lights 
These lights activate when a train makes an emergency brake application. Emergency lights are usually red, and often flash. Ditch lights 

Ditch lights, also known as auxiliary lights or crossing lights, are additional lights at the front and sometimes rear of a locomotive or cab car that are positioned closer to the track than normal headlights. They are used to make trains easier to spot, for safety. Many ditch lights are also designed to flash when a train sounds its horn, for additional visibility. Early versions of ditch lights were introduced on railroads in North America in the 1960s by Canadian National Railway, and by the 1970s Transport Canada made them a requirement on locomotives. The United States followed suit with a December 31, 1997, deadline for all "equipment operating over public grade crossings at speeds greater than 20 mph" to be equipped with ditch lights. Limited exceptions exist for historical equipment. Regulations set out the position of ditch lights, including how far apart they are from each other and their height above the rails. The predecessor of the ditch lights was the Mars Light. Strobe lights 
On remote control locomotives, a strobe light is often used to indicate the locomotive is not occupied. Strobe lights are also used on normal locomotives as a means of making the train more visible. Door indicator lights 

On passenger railroad cars, there are often indicator lights above each external door that illuminate when the door is open. These allow the train crew to ensure a train does not leave a station until all doors are closed. In newer trains, they also flash when the door closes. Train rearlights 
The rearlights on locomotives, multiple units and railcars. To ensure that the rear of the failed train is always visible, all trains are required to display three red lights at their rear: two tail lamps plus the red portion of the destination roller blind. End-of-train device

See also
 
 Headlamp

References 

Locomotive parts
Railway safety