This use of the comma is simple. If a coordinate conjunction (and, but, or) connects two independent clauses, insert a comma before the conjunction:
I prefer classical music, but Wilbur likes jazz.
I picked blackberries, and Alphonso went swimming.
When there is no coordinate conjunction between two independent clauses, punctuate with a semicolon, never a comma.
I picked blackberries; Alphonso went swimming.
I prefer classical music; Wilbur likes jazz.
Or, when you’ve got two independent clauses and no conjunction between them, you could use a period instead of a semicolon. If you do, be aware that you are promoting the independent clauses to sentences:
I picked blackberries. Alphonso went swimming.
I prefer classical music. Wilbur likes jazz.
What’s the difference? Emphasis. Degree of independence.
Tara’s Writing Studio