Select list item: Attempt to get item number 19 of a list of length 18

i get this error i have 24 pot values how do i solve this please help

1 Like

The data you receive from your Arduino has only 17 values.

People don't celebrate their 24th birthday when on attaining the age of 17.

Try Sending 24 values through your arduino, or atleast show your arduino code. (Change the file extension to .txt)

brother mine i am sending 24 values it sometime shows 24 values sometime only 17 sometimes 15 14 while on serial monitor i can see 24 values perfectly
i know there is a minor error on my mit app program Block

1 Like

Ok, but please send your aia and the ino, that would be helpful in solving your problems.

You are not using line Delimiters properly to receive only complete messages.

Standard Delimiter advice:

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.

1 Like

This is wrong:

'BytesAvailableToReceive' is a flag to show availability, it is not all of the bytes actually available - to get those, use maths block '-1', like this:

1 Like

Aniket, please upload your Sketch file (.ino).

The forum now accepts .ino files, we no longer have to change the extension to .txt

1 Like

i am using 2 arduinos so i have 2 sketch files ill sent them
Arduino_nano_analog_input_and_transfer.ino (1.5 KB)
INK_key.ino (9.8 KB)

how do i solve this i dont get complete values

.... but your App code is only using BluetoothClient1? You will need a second Client for the Second Arduino.

Also, your Blocks have far too many Button events - that should be a single "any component" Block - I'll make an example.

It's a lot of buttons for the GUI (52), a ListView might be better.

You need to be much more specific - I don't know what "this" is.

What is your code controlling?

I am using softserial to receive values from one arduino (nano) 8 analog values for 8 potentiometers
after receving from nano, second arduino(mega) send all the values to mit app inventor via 1 module

None of that is shown in your Blocks image, only BT send

Edit - my mistake, it is there in the top left corner

I am totally controlling 21 ink motors + 12 Registration Motors in a printing machine

my control is working fine every button works how i need , the only problem is the values i receive is not coming properly

it is in my program arduino read the program

Ah yes - have you corrected the App code as per my Post #6 ?

This is how you should handle a large number of Button Event Blocks:

i don't have problems regarding buttons those work fine i can operate my arduino

the problem i have isi send 24 pot values which are not shown properly on myapp