0

I want to make a program that receives data from the serial port so it can be looked for as an entry of a dictionary on Python 2.7.5 and Arduino 1.8. :

import serial #Import Serial Library
arduinoSerialData =serial.Serial('com3',9600)
y={"a":"hello","b":"How are you?"}
while (1==1):
    if(arduinoSerialData.inWaiting()>0):
        myData=str(arduinoSerialData.readline())
        print y.get(myData,"error")

I don't know what is happening, but the program always prints "error" However, if I try only printing the variable "myData" it does print exactly what Arduino is sending. Please, help.

0 Answers0