How can I create button text output that works for 2 or more seconds in App Inventor?

Hello, I've an app for my arduino robot which is connected with hc-06 bluetooth module in App Inventor. When I click "forward" button, the function 'Call.BluetoothClient1.SendText.Text' block sends the text forward value to hc-06 bluetooth device. My robot takes one step forward.
Ekran Alıntısı
Currently, my button looks like this
This is where I'm having a problem. I need a second button that gives forward text command for 2 to 3 seconds longer (or repeat the text). So, my robot can take multiple steps forward with only a button press. How can I make this button repeat it's command for 2 to 3 seconds?

I also have this "long button touch down" command, but it isn't what I wanted. I need a one click button to send "Forward" text for 2 or 3 seconds in one press only. (It is okay if a solution is to spam 'Forward' command.Help needed )


Consider renaming that COUNTER variable to STEPS_FORWARD_REMAINING, and have it count down to zero in a Clock Timer.

When you get the Long Click to request the repeating Forwards, set the counter to how many steps you want and start the Clock Timer that checks the counter, decrements it, and sends the F.

1 Like

Now i have some ideas, how should i change my blocks, sir. Can you describe for me, I'm still a new learner in this platform and I am trying every block but I couldn't figured it out.

Indirectly helped, thank you.

Here, I fixed it. This is my method to add a delay to the button command;

  1. Button pressed, function is called and code output sends "F" letter to move forward,
  2. This delay function sets 1000 ms
  3. I added "" variable after button's text output, and copy-paste the same "F" letter output below it,
  4. profit

Note; I can also add more text command outputs after delay variable in button block area as well, as much I want, (Example; Go forward for 5 seconds, wait, go forward or do somethıngs)

1 Like

(Canned Response ABG - Waiting and Timing FAQ)

Please see FAQ Section: Waiting and Timing

before you decide to code a delay() procedure in AI2.

Here is a sample project with a way to use a single Clock Timer to handle multiple deadlines ...

1 Like

This block structure will also work more clearly. Thank you

From the references you sent;

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.