python - As I can distinguish different data from Serial? -
I am trying to read the serial with different values, but I do not know how to split, because the two values There are numbers but separate sources
I first have a picacci, which sends the data converted to the dragon by the serial by the light sensor of the ADC. Second, I have a piec that sends data from the serial to the temperature sensor.
Light code PICAXE
symbol puerto = b.5 main: readadc10 puerto, w1; Read values in w1 sertxd (# w1, cr, lf) Goto main; Loop back to start temporary code PICAXE
symbol temp = B.4 readtemp temp, w0; W1 debug sertxd (# w0, cr, lf) Read values in the Goto main Python code
import pygame import sys, pygame.locals import serial * Ser = serial.Serial () ser.port = 3 ser.baudrate = 4800 while true: datos = ser.readline () grados = float (datos) print grade is the problem That picaxe send data from light and temporarily, but when python data is received, I do not know how to recognize each data.
Can anyone help me ??
Thank you!
If you have to read the light level to read the temperature and send it at the same time, But the line is divided by space.
PICAXE:
sertxd (# w0, "", # w1, cr, lf) Python:
reading = ser.readline () [read1, read2] = readings split () temperature = float (reading 1) light level = float (reading 2) if Two types of reading arise randomly, you can transmit a charaas before each person to ask how it is.
PICAXE:
sertxd ("T", # w0, cr, lf) ... sertxd ("L Python:
Comments
Post a Comment