At age 20, Barnard received a commission as Captain of the Fourteenth Regiment, United States Infantry. He opened a recruitment station in West Chester, Pennsylvania. He fought in the War of 1812 and saw action at Baltimore, Sackett's Creek, the Canadien Frontier, Fort George, La Cole's Mill, the battle of Crysler's Farm, the Battle of Plattsburgh and Lyon's Creek. At Fort George, he was promoted from captain to major in the same unit for meritorious service.