hello im not very experienced with python so sorry for any bad code
i am running ubuntu 8.10 and using pyserial
i have made a script that reads the serial input from an arduino if you are not familier with an arduino here is there website
http://www.arduino.cc/
for some reason if i try to do anything to the var raw_read[1] i get an error that says "list index out of range" but if i just print raw_read i get so why cant i use the [1] and is there a better way to separate data from serial. i am getting a couple of vars sent but i dont know how to separate them correctly. right now i am using a character in between them and using split() to put them into a list. is there any way i should send the data in ,as in format
#!/usr/bin/env python
import serial
import time
class arduino:
data1=0
data2=0
def __init__(self, _baud):
self.serial = serial.Serial("/dev/ttyUSB0", _baud)
def update(self):
self.raw = self.serial.readline()
self.raw_read = self.raw.replace("\r\n", "")
self.raw_read = self.raw_read.split("<!>")
data1 = self.raw_read[0]
data2 = self.raw_read[1]
foo = arduino(9600)
while 1:
foo.update()
time.sleep(.050)