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
Mostly dry tonight. Warm sunny spells tomorrow, with isolated thunderstorms.
The RNLI has warned of the dangers of going into cold water after a teenager was dragged unconscious from the sea by a friend.
Real Madrid won another Champions League title, beating a shell-shocked Liverpool side 3-1 in Kiev.