Sacrificial anodes are used to protect another metal from corroding. A metal with a more negative standard reduction potential is attached to the desired metal to protect it. This creates a galvanic cell were the desired metal is the cathode. The sacrificial anode will corrode leaving the cathode intact.
To show this, two cells were set up using iron nails and either zinc or nickel. The electrodes were connected by copper wire and placed in ~500mL of tap water.
|Metal||Standard Reduction Potential (V)|
Since Zinc has a more negative standard reduction potential than Iron, it corroded. Iron has a more negative standard reduction potential than Nickel so Iron corroded in that cell.