I'm having some trouble with this in Windows XP / Python 2.4 / Arduino NG Rev C. Can anyone see what I'm doing wrong?
I'm brand new to the Arduino so it's entirely possible I'm doing something very stupid.
I have this sketch successfully loaded onto the Arduino:
http://www.arduino.cc/playground/Code/SimpleMessageSystemMy Arduino is installed as Com4 under Windows, and I set it's buardrate in Device Manager to be 115200 (it installed as 9600, but the change doesn't seem to have affected it).
For simplicity I extracted the relevant parts of the above code:
Code:import serial, time
baudrate = 115200
comm = serial.Serial(3, baudrate, timeout=0.25)
for i in range(10):
comm.write("r d\r")
o = comm.readline()
if len(o) == 0: print "no response..."
else: print o
time.sleep(.5)
With pins GRD and 11 jumpered I get the following output when running the above:
Quote:d 0 0 0 1 1 1 1 1 1 0 0 0
d 0 0 0 1 1 1 1 1 1 0 0 0
d 0 0 0 1 1 1 0 1 0 0 0 0
d 0 0 0 1 1 1 0 1 0 0 0 0
d 0 0 0 1 1 1 0 1 0 0 0 0
no response...
no response...
d 0 0 0 1 1 1 1 1 0 0 0 0
d 0 0 0 1 1 1 1 1 0 0 0 0
no response...
With all pins open (no jumpers) I get the following:
Quote:no response...
d 0 1 0 1 1 1 0 1 1 1 0 0
d 0 1 0 1 1 1 0 1 1 1 0 0
d 0 1 0 1 1 1 0 1 1 1 0 0
d 0 1 0 1 1 1 0 1 1 1 0 0
no response...
no response...
no response...
d 0 0 0 1 1 1 0 1 1 1 0 0
d 0 1 0 1 1 1 1 1 1 1 0 0
Ok, so far so good, the digit 3rd from the right is Pin 11 and it's indicating its status well. However, if I attach a button across the two pins and press and release I get this:
Quote:no response...
d 0 0 0 1 1 1 1 1 0 0 0 0
d 0 0 0 1 1 1 0 1 0 0 0 0
no response...
no response...
d 0 0 0 1 1 1 1 1 0 0 0 0
no response...
d 0 0 0 1 1 1 1 1 0 0 0 0
d 0 0 0 1 1 1 1 1 0 0 0 0
d 0 0 0 1 1 1 1 1 0 0 0 0
Three questions:
1) How do I make it update faster? When I was pressing that button its status never changed. I have a feeling its reading from a buffer. Do I need to clear that buffer when I read from it? If so, how?
2) Is it normal to get no response from the Arduino when querying it? Even when I increased the timeout to 1 I still get the no responses...
3) And on a minor note, why were the other pins fluctuating even when nothing was attached to them?
Thanks for any help.