             // now I have to add sensors one by one
             int j = i + 3;
             while (j < str_length){
-              if (tmp_str[i] == 'P' || tmp_str[i] == 'p'){
+              if (tmp_str[j] == 'P' || tmp_str[j] == 'p'){
                 int sensor_index;
                 sscanf(tmp_str + j + 1, "%d", &sensor_index);
                 motors_control.add_sensor(motor_index, POTENTIOMETER, sensor_index);

#include "jenny5_types.h"

byte potentiometers_pins[4] = {0, 1, 2, 3};
t_limit_pair potentiometer_limits[4] = {{500, 1000}, {0, 1023}, {200, 600}, {300, 600}};

byte ultrasonic_trig_pins[2] = {48, 50};
byte ultrasonic_echo_pins[2] = {49, 51};

  Serial.println(F("Bx# // Gets the status of the button x."));
  Serial.println(F("Px# // Gets the position of the potentiometer x."));
  Serial.println(F("Ix# // Gets the status of infrared sensor x."));
  Serial.println(F("G# // Prints for each motor: [sensor index, sensor type, sensor value, is whithin limits]"));
//  Serial.println(F("PL# // sets the min (lower) position for potentiometer x."));
//  Serial.println(F("PU# // sets the max (upper) position for potentiometer x."));
  
