Button With LED

Hello Arduino Forum,
I am trying to make a basic morse code program. The circuit is attached.
Basically, I am trying to make a circuit where when you press the button, it makes a short flash and then a long flash (which is morse for A). Ignore all the stuff about buttonPinB, I’m going to expand that later. I tried using an if function, but it didn’t work. Here is my most recent code:

const int led=13;
const int buttonPinA=2;
const int buttonPinB=3;


int shortFlash() {      //led flashes quicly
	
        delay(2000);
        digitalWrite(led, HIGH);
	delay(100);
	digitalWrite(led, LOW);
	delay(5000);
}

int longFlash() {      //led flashes long
	digitalWrite(led, HIGH);
	delay(1300);
	digitalWrite(led, LOW);
	delay(1075);
}

void setup() {
  pinMode(led, OUTPUT);
  pinMode(buttonPinA, INPUT);
}


void loop() {
 
  
  boolean buttonReading = digitalRead(buttonPinA);
  
  while  (buttonReading == HIGH)      //if button is pressed
  {  
    shortFlash;             //do a short flash
    longFlash;
  }
  digitalRead(buttonPinB);
  if (buttonPinB==HIGH)
  {
  longFlash;
  shortFlash;
  shortFlash;
  shortFlash;
  }
  
  

}

Help would be much appreciated.
Thanks,
rhausman :confused:

When calling a function, always use '(' an ')', like this:

  shortFlash();             //do a short flash
  longFlash();

Do you want to run that code as long as the button is pressed ? or only once at a press of a button ?

Do you know how a button with pullup (or pulldown) resistor should be connected ? I'm not sure if you done it right.

Peter_n: Do you know how a button with pullup (or pulldown) resistor should be connected ? I'm not sure if you done it right.

Yeah, there's a problem with the button connection. The pushbutton's pins are connect at vertical and have the switch between the "horizontal" pins. You just have to change the yellow wire to the right side. Beside that, I would change the while statement for a if one, because it will test just one time if the button is pressed, and if you want to send two A's, you just need to press again.

Thank you both. I have made the suggested hardware change and altered the code to include the empty parameter parentheses. I have tested the button controlling the LED and it worked. Therefore there is still an issue with the code. any Ideas? Final thing: Ideally, I would make a full alphabet. However, that won't really be possible with my quarter size breadboard. Is there a way to fix this with code, or should I just buy a bigger breadboard? Thanks again for all the help! @gustavori @Peter_n

shortFlash and longFlash are functions: Should declare them with VOID, not INT

@ Paulcet Functions can be declared with int, if that is what he wants to return. Here he is not returning anything so he should use void but that is probably not the reason why it isn't working. @ rhausman If all you say is working then you should probably try taking the code out of the function and testing it by itself.

-ma7730