Skip to content

wormoworm/semaphore-servo-controller

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

semaphore-servo-controller

What is it?

An Arduino program for controlling servos that animate model railway semaphore signals. It takes input from up to four sensors, setting the signal to the "danger" position when any sensor is activated. The servo is animated so that the signal "bounces" when returning from clear to danger, which is often the case on the prototype. A full write-up of the project can be found here.

How does it work?

The code loops around a simple state machine, waiting for input from the sensors and moving the servo accordingly. Image

The main loop follows this state machine ad-infinitum:

void loop() {
  // Wait for "danger" to be requested.
  waitForDanger();
  // Set the signal to "danger".
  setToDanger();
  // Wait for the minimum danger time.
  waitForMinimumDangerTime();
  // Also wait until "clear" is requested.
  waitForClear();
  // Return the signal to "clear".
  setToClear();
}

All the major aspects of the program are covered in the write-up.

About

An Arduino program for controlling servos that animate model railway semaphore signals.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages