2
Good morning, I’m having problems receiving the data that the Arduino is sending, what I want to read the line information, play this information in a variable and compare the values in Raspberry. The problem is that as I want to separate the information by line, I have to use the command in Arduino Serial.println, which in Raspberry generates, in addition to the desired number/text, the characters of jump line " r n", generating conflict in my comparison in rasp. How can I separate this information without generating these characters?
Code on the Arduin:
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println("1");
delay(500);
Serial.println("2");
delay(500);
Serial.println("11");
delay(500);
}
Code on the Raspberry:
import serial
comunicacaoSerial=serial.Serial('/dev/ttyUSB0',9600)
k=str()
while 1:
k=comunicacaoSerial.read()
int_k = int(k)
print(k==1)
Tried to give a
.split('\n')
in its variable 'k'?k = k.split('\n')[0]
– Vinicius Bussola