Anyone can help me for MIT app inventor for ListPicker function... Do I need to insert anything or tick any boxes so that it will change the ListPicker image when running some command? Because I have uploaded four different image on MIT app inventor media section and I want the ListPicker to change to different image under different condition
Hello Charlotte,
To change the ListPicker's image when running different commands, you have to use the Blocks editor. What you are showing is the Designer, a place for you to design what your app looks like. To change the app's behavior, you have to use the Blocks editor. Since you are a new, I will guide you through the steps.
- On the top right corner, click on Blocks.
- In the Blocks editor, click on ListPicker1.
- You should see a lot of blocks for ListPicker. Scroll down and find the dark green
set ListPicker1. Image
block and drag that out into an empty place in the workspace.
- You will see a red block connected to the socket. Change the red block to the image name of the image that you want to set the ListPicker to. I will set it to condors-1.jpg.
- We are nearly done. When do you want the image to change? If you want to change the image after the SetImageToDuck button is clicked, click on that component.
- You will then see a list of blocks for SetImageToDuck. See the
when SetImageToDuck.Click
yellow block? Drag it out, and drop it into a blank space in the workspace.
- Now you have two sets of blocks, the event and the setter, but they still don't do anything. Connect them together like this.
Yes I know that I need to use the blocks in order to operate... but does that means that for the designer part I am correct. For example I don't need to put anything in those selection boxes or tick any boxes?
These are my blocks...actually I wanted to make an app that connects to Arduino via Bluetooth but I don't know why it doesn't work when I connect the app to the bluetooth and the app doesn't work the way I wanted to... I can't find out the problem but I think there is no problem with the Arduino bcaus it works well when I run the serial monitor... Can you help me to have a look?
You actually do not need to do anything for the Designer, in the Designer, you only set the Image of the ListPicker to the image that you want to show when the app has first been opened.
If I am not wrong, you shouldn't use the when ListPicker1.BeforePicking, because that event occurs only when the user is about to pick it. You should set it when the screen initializes, more specifically, this.
Thanks for the suggestion.. Let me try and see
It still doesn't work... I think the problem should be somewhere around if - then because I am using the ultrasonic sensor on Arduino to detect the distance of an object and it works well in serial monitor shown. So I am not sure what is the problem with this MIT app inventor blocks
Let me have a quick look...
Sorry, because I do not have that Arduino here, I cannot guarantee. Can you try Do It to debug your blocks, like this?
Right click the blocks you want to debug, and then select Do It in the menu.
so just debug for each and every blocks?
Try to debug these:
- The
BluetoothClient1.AddressesAndNames
block here.
- After that, debug these: the
BluetoothClient1.IsConnected
,call BluetoothClient1.ReceiveText
and thecall BluetoothClient1.BytesAvailableToReceive
blocks in here.
After you right click and Do It blocks that can connect to sockets, they should have a message popping up, just like this.
Tell me the results of the blocks.
All good here...
This is the problem here (probably not your fault) - if you split an empty text at spaces, you will get the first item as an empty text.
And so, the first item will become an empty text. So, the image of the ListPicker will not be set because it does not fit any of the conditionals here.
And here, List is a list with a length of 1, so you cannot select item number 2 in a list with a maximum index of 1.
Do you mean this block part? What can I do if I don't split an empty text at spaces?
So here will be just 0 and 1 right?
No, global list is just something like this.
global Script itself is an empty text, so you cannot avoid it. If it is empty text, it probably means that it has received nothing or received empty text.
Because you set a conditional that executes only when BytesAvailableToReceive is > 0, it will do nothing.
So does that means that maybe I need to change the way of code in Arduino? Is there any way that I can change the blocks instead changing the code in Arduino?
So how should I correct this part?
You probably have to look into your Arduino code and check if anything is wrong with it.
BytesAvailableToReceive is currently 0. I am not an expert in this, but it seems that something is wrong.
Do you know Arduino? Because I can't really think of another method of sending the data to the MIT app inventor
Not much, but I am checking. I am checking it, but I don't see problems in the code (yet).
Ya so I think the problem is more on the MIT app inventor
So should I change the value instead of putting 0? Actually what is the meaning of this block BytesAvailableToRecieve?
According to the documentation, it
Returns number of bytes available from the input stream.