Information is sending too quick to arduino

With this line of code it works well with low values but when i go with anything 200+ i get the wrong value. Is there a way to send it slower while keeping the while loop? Or does it need complete change

image

Welcome @Scoops,
in AI2 a "typical" delay function is not available but you can use clocks, instead.
In your case you can set two clocks, let's say Ck_increase and Ck_decrease.
Each clock shall have a period of 10 milliseconds (temptative value: depending on how much fast you want to update the BT line, but avoiding the data missing).
When the click event is raised, you just enable one of the two clocks depending on the input value (< or >).
The enabled clock will send one increase (or one decrease) every 10 millisecond. When the last value is sent, the clock disables itself.
Please be aware that the clocks shall be both initialized to disabled in the screen1 initialize and their capability to run in background shall be disabled.
If it is not clear, please let me know.

EDIT : since one picture is better than 100 words:

The version below also disables the button while the timers are running and re-enables it at the end of the increase/decrease operations.

Thank you very much! I will test it tomorrow since my arduino is at school. I'll keep you updated

1 Like

This does work without any problems!! Thank you very much!

Nice to read that !!!
Best wishes for your project. :hugs:

1 Like

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