Oswald Davies described his actions in failing to use a level crossing properly as "terrifying", and said he was thankful nobody had been killed.
He did not follow the instructions to phone the signalman to get permission to cross.
As he crossed, the barrier on the opposite side came down, blocking his path. He stopped his lorry and had just got out of the cab when he was hit by the Milford Haven to Manchester Piccadilly train.
The court heard how the train driver had seen the lorry on the track, applied the emergency brake, ran out of his cab and dragged a colleague with him, helping them both avoid injury.
49 passengers were on board the train, travelling at 68mph, and four were taken to hospital suffering minor injuries.
The crash cost Arriva Trains Wales £819,821 - including the recovery of the train, repair costs and the running of replacement services.
The line was closed for two days for the vehicles to be recovered.
Chief Inspector Sandra England from British Transport Police Welsh Sector said: "It is astounding that no one was seriously injured or killed. Davies' actions not only put rail staff and passengers' lives at risk, but also caused massive disruption to rail infrastructure."
"Taking a chance at a level crossing can have dire consequences. Stop, think and be sensible, because one moment of impatience could result in lives being destroyed."
More top news
Most places will see a dry, bright day with patchy cloud but also some warm sunny spells, and it'll be less breezy than on Friday.
Members of the RMT union are walking out for three days from today in a row over new trains causing disruption to bank holiday services.
The Bank Holiday is here! Which is usually a recipe for wet weather! Yes, we will get our fair share. But it's not all doom and gloom!