Coding a LED dimmer with 2 buttons + More functions decided with millis()

So I am making a code where I have a LED dimmer with 2 buttons. This part I have figured out.

Now what I need help with, is adding a code that detects how long the buttons are pressed.

When the button that turns the brightnes down is pushed for <1 second it won’t dim the LED but make it blink by turning off for a short amount of time. So the button will only dim the LED if it’s pressed for >1 sec.

The same with the button that turns the brightnes up, but this one will blink with the max brightnes for a short amount of time if the button press is <1sec. Making this dim the brightnes up if the press is >1 sec

Here’s my code:

const int brightnessUp = 4;
const int brightnessDown = 2;
const int ledPin = 3;
const int maxBrightness = 12;

int brightness = maxBrightness;
int interval=1;

void setup() {

pinMode(ledPin, OUTPUT);

pinMode(brightnessUp, INPUT);
pinMode(brightnessDown, INPUT);

void loop(){
if (digitalRead(brightnessUp) == HIGH && brightness < maxBrightness){
brightness = brightness + interval;

if (digitalRead(brightnessDown) == HIGH && brightness > 0){
brightness = brightness - interval;

analogWrite(ledPin, map(brightness, 0, maxBrightness, 0, 255));


Thanks for any help!