my group and I are interfacing Arduino and python on our Raspberry pi zero w so that an IR receiver connected to the Arduino sends the corresponding characters to python, which it does.However, we are trying to make the data sent to Ardunio do things now but Python is not recognizing the data. Here is the python code:
from time import sleep
import serial
ser = serial.Serial('/dev/ttyAMC0', 9600) # Establish the connection on a specific port
while True:
print (ser.readline()) # Read the newest output from the Arduino
IR = (ser.readline())
if IR == 'FF6897\n':
print('0')
else:
print('wtf')
and here is the Ardunio code:
void setup() {
Serial.begin(9600); //set band rate
Serial.println("Ready"); //print "Ready" once
}
void loop() {
char inByte = ' ';
if(Serial.available()){ //only send data back if data has been sent
char inByte = Serial.read(); //read the incoming data
Serial.println(inByte); //send the data back in a new line so that it is not
}
delay(100); //delay for 1/10 of a second
}
When button 0 is pressed on the remote python will receive
b'FF6897\r\n'
despite all the other stuff the FF6897 is what we expected. Therefore, we told python that is it sees that code print "0" However it just keeps printing "wtf" because it does not recognize the code for some reason. Any ideas how to make what Python is receiving something we can actually use?