This very simple scheme allows you to quickly get the train on your schedule. You can adjust the movement time and the train stop time. Train acceleration and braking are also configurable. By changing the schedule parameters in the sketch, you can create any type of automatic movement. Just turn on the power and your train leaves to way.
Changing the time parameters in the sketch:
// 1 | 0 > Time < 5 sec
if (counterScheduler <= 5) {
......
// 2 | 10 sec > Time < 15 sec
if ((counterScheduler >= 10) && (counterScheduler <= 15)) {
......
// 3 | Change direction
if (counterScheduler == 16) {
.... etc.
creates a timetable.
Variables:
int brakingDelta = 5;
int accelerateDelta = 6;
define the parameters of movement the train
The direction of the train is determined by the state of the pins D6 and D7:
// Set default direction to FORWARD
digitalWrite(L298_IN1, HIGH);
digitalWrite(L298_IN2, LOW);
You can endlessly change this sketch to get new options for automatic train movement.
Welcome aboard!
Comments