user15539: I am trying to get Arduino Uno with Raspberry Pi to communicate with each other. I want the python script to write a message and for my Arduino to read it. This was working before, but I came back a week later and it stopped. Essentially, I want the Raspberry Pi to write '3' and for my Arduino to recognize this 3 and light up some LEDs. Where do you think I am going wrong? The Arduino works when testing it through the IDE and Serial Monitor. There are no errors when running the python script, the LEDS just don't light up, so I assume there is some miscommunication.
Python Code
import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write('3')

Arduino Code
String serialRead;
int val;
void setup() {
  Serial.begin(9600);
  strip.begin();  
  strip.setBrightness(25);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  serialRead = Serial.read();
  if (Serial.available() > 0) {
    val = Serial.read();

    if (val > '0' && val <= '9') {
      Serial.println(val);
      val = val - '0';
      Serial.println(val);

      if (val == 3)
      {
        //strip.setBrightness(100);
        colorWipe(strip.Color(127, 127, 127), 50);
        colorWipe(strip.Color(0, 0, 0), 50);        
      }
    }
  }
}


user8561: Just at a glance:
Your loop consumes the byte and stores it in serialRead, so there is probably no available data at the outer if, so it is never entered.
Try deleting this line:
serialRead = Serial.read();


15539: <p>I am trying to get Arduino Uno with Raspberry Pi to communicate with each other. I want the python script to write a message and for my Arduino to read it. This was working before, but I came back a week later and it stopped. Essentially, I want the Raspberry Pi to write '3' and for my Arduino to recognize this 3 and light up some LEDs. Where do you think I am going wrong? The Arduino works when testing it through the IDE and Serial Monitor. There are no errors when running the python script, the LEDS just don't light up, so I assume there is some miscommunication.</p>

<p>Python Code</p>

<pre><code>import serial
ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write('3')
</code></pre>

<p>Arduino Code</p>

<pre><code>String serialRead;
int val;
void setup() {
  Serial.begin(9600);
  strip.begin();  
  strip.setBrightness(25);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  serialRead = Serial.read();
  if (Serial.available() &gt; 0) {
    val = Serial.read();

    if (val &gt; '0' &amp;&amp; val &lt;= '9') {
      Serial.println(val);
      val = val - '0';
      Serial.println(val);

      if (val == 3)
      {
        //strip.setBrightness(100);
        colorWipe(strip.Color(127, 127, 127), 50);
        colorWipe(strip.Color(0, 0, 0), 50);        
      }
    }
  }
}
</code></pre>
 8561: <p>Just at a glance:</p>

<p>Your loop consumes the byte and stores it in <code>serialRead</code>, so there is probably no available data at the outer <code>if</code>, so it is never entered.</p>

<p>Try deleting this line:</p>

<pre><code>serialRead = Serial.read();
</code></pre>
