title: How to send an int from Python to an Arduino in order to use it as an argument for the neopixel function setPixelcolor()?
body: <p>I am trying to send an int number from Python to an Arduino using PySerial, using <code>.write([data])</code> to send with Python and <code>Serial.read()</code> or <code>Serial.readString()</code> to recieve on the Arduino, then <code>.setPixelColor()</code> and <code>.show()</code> to light a LED on a matrix which position corresponds to the <code>int</code> sent by the arduino (I am using the Duinofun Neopixel Shield).</p>
  
  <p>But It does not seem to work properly, and I can't use the Serial Monitor as I am sending my data as the port would be busy.</p>
  
  <p>I have tried to input a number myself using <code>Serial.readString()</code> then converting the string to an int and finally putting in into my function that displays the LED.</p>
  
  <p>It does work properly when I do this, but when I send some data over, all the previously lit LEDs suddenly switch off which can only be caused by a reset of the Arduino board as far as I know.</p>
  
  <p>This is the python code, it simply sends an int chosen by the user</p>
  
  <pre class="lang-py prettyprint-override"><code>import serial
  
  a = int(input('Enter pixel position : '))
  ser = serial.Serial("COM16", 9600)
  
  ser.write([a])
  </code></pre>
  
  <p>And this is the part of the Arduino program that reads the incoming data.</p>
  
  <pre class="lang-c prettyprint-override"><code>Adafruit_NeoPixel pixels = Adafruit_NeoPixel(40, 6, NEO_GRB + NEO_KHZ800);
  
  void setup() {
    // put your setup code here, to run once:
    pixels.begin();
    Serial.begin(9600);
  }
  
  void loop() {
  
    String a = Serial.readString();
    int b = a.toInt();
    pixels.setPixelColor(b, 30,30,30);
    pixels.show();
    Serial.println(a);
  
    delay(1000);
  
  }
  </code></pre>
  
  <p>All the LED switch off when I send some data, except the first LED which position corresponds to a 0 used in the <code>.setPixelColor()</code> function.</p>
  
  <p>Problem is, the LED should light to the corresponding int sent by Python (e.g light the fifth LED for an int of 4).</p>