Barnum entered the U.S. service on May 13, 1861, as captain of Company I, 12th N.Y. Infantry, at the age of 27; and afterward in October 1861 was promoted to major of that regiment.
He served with distinction with that command, including the Peninsula Campaign under Maj. Gen. George B. McClellan, until July 1, 1862, when he was dangerously wounded by gunshot through the left ilium, at Malvern Hill, Virginia.
His body was abandoned and fell into the hands of the enemy; afterward, he returned to the Union lines, sufficiently recovered from his injury by October 4, 1862 to accept a commission as colonel in the 149th New York.
On December 23, in pursuance of an order of Maj. Gen. George H. Thomas, he was detailed to convey the captured flags taken by the 149th New York and other regiments to the War Department at Washington, and also received a leave of absence for twenty days, to take effect after the performance of such duty.
While absent in the performance of this duty, Barnum received further surgical treatment, and being disabled for field duty, was placed on recruiting service for the regiment, and again joined his command at Kennesaw Mountain, Georgia, about June 26, 1864, and a few days later was wounded by a fragment of shell in the right side at Peach Tree Creek, Georgia, July 20, 1864.
On September 10, following the death of Colonel David Ireland at Atlanta, Barnum assumed command of the 3rd Brigade, which he retained for the rest of the war.