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);
}
}
}
}