Need help with a clock and delay

I need this to fire 3 times like a pulse from bluetooth while holding down the button, can someone help me write this up?

Start by reading the entries in

on event based programming, and why you can't wait in AI2.

Once you have that clear, here is how to send 3 messages over BLE spaced a second apart, starting when you hold down a button, repeating until either you reach 3 messages or the button is released. ...

Init a global Remaining_blasts to 0.
Pull in a Blast Clock (rename it) and set it to Disabled , 1000 ms, Repeating, in the Designer.

When Button5 Touchdown
   set global Remaining_blasts to 3
   enable Blast Clock 
end touchdown

when Blast Clock Timer
   if global Remaining_blasts > 0 then
      set global Remaining_blasts to global Remaining_blasts - 1
      send a message
      vibrate or make a noise
     disable Blast Clock 

when Button5 TouchUp
   set global Remaining_blasts to 0
end when