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
The director of the Royal College of Nursing in Wales says nurses are prepared to ballot on strike action if the current pay cap remains
All seven Welsh NHS health boards have been sent a letter asking them to review the cladding on buildings following the Grenfell fire.
Vets were left baffled by what was causing Diesel's tummy problems...