I've created an application with which I can control a robot in arduino with a Bluetooth module. I installed the application on my smartphone but after a few commands, the application is crashing, after that I receive the message "Application stopped working" and Close app or wait.
There are some screenshots.
Do the commands you send reach the arduino? Can you see them in the serial monitor ? If so how many times is it sending everything ?
Yes, I can see them in serial monitor, is like they appear a lot of times per seconds, but just the commands when the button is TouchUp. The commands from TouchDown appear only when I press the button, like one time if I just click it
I haven't used the Bluetooth stuff before but if I was to guess at the problem I would say your overloading the apps buffer causing it to crash.
you can test this by creating a variable and check it when you send a command so that it is only sent a few times (just in case some are not read). Try that and see if the app still crashes.
Again I might be completely wrong, its just my best guess.
Sadly, that is not the problem.
Ok next idea. Once you check that bluetooth is connected and it is connected put the block Clock1.TimerEnabled to false in there and see if that works.
Do you have more screens in the app? How do you switch them?
The blocks you've shown shouldn't be a problem. Are you doing something unusual? For example, very fast button clicks?
Actually there are a number of errors in your blocks that luckily do not cause a crash but I think the issue with touch up/ touch down is that often they are not sensed as a single touch. 'Clicked' is much more reliable - you can use a Boolean variable to determine which command to send.
In future: Right-mouse in the Blocks work area and select "Download Blocks as image" so that we can read them easily.
- Joel is right to suspect that Clock1's constant calling could interrupt your command sending. It is just not the best way to code - you should perform the check just before the command is sent, therefore in the button event, no clock required.
Use If Then Else! A simple example:
List is already populated:
Use the Screen Error Block:
Your crash could also be caused by something in the Arduino Sketch. Upload it to this Topic (by changing it's file extension to .txt ) for someone to study for you.
I don't see a Web1.GotText event for that Web1 call, nor any hint what URL you are requesting.
I've tried what you said, thank you, but still, the application is crashing and after that appear the message with "close app", even if I have the Screen error block, there are no message sent and the app go down.
I use just one screen, I'll put here the code in arduino and a new image of blocks.
code.txt (5.0 KB)
Thank you all.
As it already has been said:
- Your clock timer event is useless
- There is a web get method without a web got text event
Generally to find out more about the runtime error: use logcat
Hello again Mada
You have four motors and two servo motors to control. Your Sketch is OK but:
- You should only call the bluetooth procedure (bad name!) if the state value has refreshed.
- Use elapsed milliseconds instead of delay().
How are the motors being powered? How are the electronics being cooled? An issue in either department can crash everything.