Is it Me or is it I?

Me myself and IIs it Me or is it I?
1: My friends and I went to the beach. (the subject)
2:The waiter gave my friends and me a beer. (the object)
1. My friends and I went to the beach. (I is the subject of the sentence therefore use the subject pronoun I)
2. The waiter gave my friends and me a beer. (Me is the object of the sentence therefore use the object pronoun Me)