I assume that you're trying to control whether the led is on or not with the button and how brightly lit it is when it is on with the pot. If so, when you detect a transition and flip the ledOn variable, test that variable and either analogWrite what you read from the pot, or zero if the led is supposed to be off. Get rid of the later digitalWrite.