MOTORCYCLE TURN SIGNAL DESIGN IDEAS

hello everyone :slight_smile:
if anyone is willing to help me, I really appreciate it
I'm having problems here, because I'm still learning, just learning Arduino as long as there is fukg Virus #stay at home
this is blink 3x my problem is a bug on the buttonState if you switch several times, the start of the led should be off but this is high ......... and how to add int, for example: led blink 2x for 3 times and led blink 3x for 3 times continuously
and this is my code:

const byte LedPin = 13;
long currentTime;
const int pinPot = A0;
int sensor = 0;
int buttonState = 0;      
const int  buttonPin = 2;

void setup()
{

  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(buttonPin, INPUT); 
  digitalWrite(13, LOW);
 #define INTERVAL 5L
 #define BLINK_TIMES 3
 #define BLINK_TIMES_1 2
}

void loop()
{
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH) {
  digitalWrite(13, LOW);}
  else{
 sensor = map(analogRead(pinPot), 0, 1023, 500, 5);
static unsigned long lastBlink = 0;
static int count = 0;
unsigned long now = millis();
if(count > 0) {
       count -= blink();
       lastBlink = now;
   } else {
       if(now - lastBlink >= INTERVAL*sensor) {
           count = BLINK_TIMES;                    
}
}
}
}
int blink()
{   static unsigned long lastFlip = 0;
 static int count = 0;
 bool last = false;
 unsigned long now = millis();
if(now - lastFlip >= sensor) {
   digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
   lastFlip = now;
   count++;
   if (count == 2) {
     count = 0;
     last = true;
     }
  }

  return (last) ? 1 : 0 ;
}

thank you for replying. 8)

Read the how to use this forum-please read sticky to see how to properly post code and some advice on how to ask an effective question. Remove useless white space and format the code with the IDE autoformat tool (crtl-t or Tools, Auto Format) before posting code.

What does your code actually do? How is that different from what you want the code to do?

How is the button switch wired? Is there a pulldown resistor?

@groundFungus thanks for your replay,and iam sorry about that(useless white space and format the code )
for button switch? yes i give pulldown resistor 10k,if I press the button quickly then that happens is digitalWrite(13, HIGH), should be digitalWrite(13, LOW)
and the working principle that I want is: a 3x blink led, where the blink speed is regulated by a potentiometer in A0 and port 2 functions as a momentary switch,thanks