<P> "The Star - Spangled Banner" was recognized for official use by the United States Navy in 1889, and by U.S. President Woodrow Wilson in 1916, and was made the national anthem by a congressional resolution on March 3, 1931 (46 Stat. 1508, codified at 36 U.S.C. § 301), which was signed by President Herbert Hoover . </P> <P> Before 1931, other songs served as the hymns of American officialdom . "Hail, Columbia" served this purpose at official functions for most of the 19th century . "My Country,' Tis of Thee", whose melody is identical to "God Save the Queen", the British national anthem, also served as a de facto anthem . Following the War of 1812 and subsequent American wars, other songs emerged to compete for popularity at public events, among them "America the Beautiful". </P> <P> On September 3, 1814, following the Burning of Washington and the Raid on Alexandria, Francis Scott Key and John Stuart Skinner set sail from Baltimore aboard the ship HMS Minden, flying a flag of truce on a mission approved by President James Madison . Their objective was to secure an exchange of prisoners, one of whom was Dr. William Beanes, the elderly and popular town physician of Upper Marlboro and a friend of Key's who had been captured in his home . Beanes was accused of aiding the arrest of British soldiers . Key and Skinner boarded the British flagship HMS Tonnant on September 7 and spoke with Major General Robert Ross and Vice Admiral Alexander Cochrane over dinner while the two officers discussed war plans . At first, Ross and Cochrane refused to release Beanes but relented after Key and Skinner showed them letters written by wounded British prisoners praising Beanes and other Americans for their kind treatment . </P> <P> Because Key and Skinner had heard details of the plans for the attack on Baltimore, they were held captive until after the battle, first aboard HMS Surprise and later back on HMS Minden . After the bombardment, certain British gunboats attempted to slip past the fort and effect a landing in a cove to the west of it, but they were turned away by fire from nearby Fort Covington, the city's last line of defense . </P>

Who was the president when the national anthem was written