Thursday 15 August 2013

python - Arduino hit counter -


We are having trouble getting data from the serial port. We have this python code, its purpose is to get value from a file It then enhances it, we are trying to connect it with the arduino with a motor servo like when it detects a pay increase, servo moves.

  # Fetch counter # import time import urllib import serial # USB serial connection Last_counter: b = b.strip () while (True): counter = open ("hitcounter.txt") For arduino ser = serial.Serial ('COM3', 9600) last_counter = open ("hitcounter.txt") for b. ) In a counter: a = a.strip () delta = et (a) - int (b) ash = delta + 1 print gate print "counter:% s, delta:% s"% (a, delta) x = Print (% s) (print) (%) (print) (%) % (Y) b = a time.Sol (10)    

In your code: After (True):

The line is not indented after that, so code is not part of the block. Your code will only have an idle loop here. Assume that I understand your code logic:

  # # Fetch counter # import time import urlib import serial # USB serial connection arduino ser = serial (Serial): Counter = Open ("hitcounter.txt") for A = A while while (True): B = B. Strip (last) if last_counter: b = b.strip () last_counter = Open ("hitcounter.txt") Open the .strip () delta = int (a) - int (b) gate = delta + 1 print ass print "counter:% s, delta:% s"% (a, delta) X = chr (ser.write (chr ord (chr (delta))))) print type (x) print "% S"% (x) y = ser.write (ass) print type (y) print "% s"% (y) b = one time.So (10)    

No comments:

Post a Comment