You should sound a sharp blast of your horn when:

In situations that present no immediate danger, a light tap of the horn is generally sufficient to get the attention of others. A sharp blast of the horn should be used in situations of actual danger, such as when another vehicle is in danger of hitting you. You should not use your horn to encourage someone to drive faster or get out of the way.
DMV Writen Test