The present invention relates to a method for covalently attaching a compound to a stainless steel, tin, iron, or titanium substrate, by contacting exposed surface(s) of the substrate with a synthetic pilin peptide containing a disulfide loop derived from the C-terminal receptor binding protein of Type IV P. aeruginosa (T4P) pilin, to bind the pilin peptide to the exposed surface(s), and covalently attaching the compound to the pilin peptide. Also disclosed are a substrate formed by the method and a biosensor device that uses the uses. Also disclosed are methods for improving the corrosion resistance, adhesive force, hardness and electron work function of certain metals.