Select list item: List index too large Select list item: Attempt to get item number 2 of a list of length 1: () please help to this code as soon as possible please

This impossible without the .ino file.

as you have changed the blocks i did it all and now it is not showing the list index error . thank you very much. but now i am facing another problem.


see this is our app inter face , but the switches are not working at all and after opening the app the app automatically closes after a few minutes.

please help in this problem.

please reply

Did yo got any solution .Please reply .

1 Like

BT_Control_4Load.ino (2.0 KB)
This is the ino file. Pls check it out and help us.

I don't see anything obviously wrong in your .ino sketch:

#include <EEPROM.h>
#include <SoftwareSerial.h>
SoftwareSerial BT_Serial(2, 3); // RX, TX

#define Relay1 4 // Load1 Pin Out
#define Relay2 5 // Load2 Pin Out
#define Relay3 6 // Load3 Pin Out
#define Relay4 7 // Load4 Pin Out

char bt_data; // variable to receive data from the serial port
int load1, load2, load3, load4, power;

void setup(){
Serial.begin(9600);
BT_Serial.begin(9600); 

pinMode(Relay1, OUTPUT); digitalWrite(Relay1, 1); 
pinMode(Relay2, OUTPUT); digitalWrite(Relay2, 1); 
pinMode(Relay3, OUTPUT); digitalWrite(Relay3, 1); 
pinMode(Relay4, OUTPUT); digitalWrite(Relay4, 1); 
  
load1 = EEPROM.read(1);
load2 = EEPROM.read(2);
load3 = EEPROM.read(3);
load4 = EEPROM.read(4);

power = EEPROM.read(5);
delay(500); 
}

void loop() {
if(BT_Serial.available()>0){bt_data = BT_Serial.read();}

if(bt_data == 'A'){load1=0;EEPROM.write(1, load1);}
if(bt_data == 'a'){load1=1;EEPROM.write(1, load1);}

if(bt_data == 'B'){load2=0;EEPROM.write(2, load2);}
if(bt_data == 'b'){load2=1;EEPROM.write(2, load2);}

if(bt_data == 'C'){load3=0;EEPROM.write(3, load3);}
if(bt_data == 'c'){load3=1;EEPROM.write(3, load3);}

if(bt_data == 'D'){load4=0;EEPROM.write(4, load4);}
if(bt_data == 'd'){load4=1;EEPROM.write(4, load4);}

if(bt_data == 'E'){power=0;EEPROM.write(5, power);}
if(bt_data == 'e'){power=1;EEPROM.write(5, power);}

bt_data = '0';
  
if(power==1){  
digitalWrite(Relay1, 1); 
digitalWrite(Relay2, 1); 
digitalWrite(Relay3, 1); 
digitalWrite(Relay4, 1); 
}else{
digitalWrite(Relay1, load1); 
digitalWrite(Relay2, load2); 
digitalWrite(Relay3, load3); 
digitalWrite(Relay4, load4);
}

 BT_Serial.print(power); //send distance to MIT App
 BT_Serial.print(";");
 BT_Serial.print(load1); //send distance to MIT App 
 BT_Serial.print(";");
 BT_Serial.print(load2); //send distance to MIT App 
 BT_Serial.print(";");
 BT_Serial.print(load3); //send distance to MIT App 
 BT_Serial.print(";");
 BT_Serial.print(load4); //send distance to MIT App 
 BT_Serial.println(";");
  
delay(500);  
}

Show us your revised blocks and exported .aia file:

(Canned Reply: ABG- Export & Upload .aia)
Export your .aia file and upload it here.
export_and_upload_aia

BT_Control_4Load.aia (292.2 KB)
pleaase check.





Screenshot 2023-11-01 082001

P.S. These blocks can be dragged directly into your Blocks Editor workspace.

Dragging blocks

The > 10 bytes check was unnecessarily restrictive, since the Delimiter test was all that was needed.
To avoid a list index overflow, I added a list length test.

If this does not work, add a new Label and use it to show the result of the split.

Also, you are receiving at 1000 ms but transmitting at 500 ms, so you will not keep up with the incoming data. Reverse the situation: Run Clock1 at 200 ms to read faster than you write.