Go Down

Topic: Python Firmata trouble (Read 520 times) previous topic - next topic



When using this script to blink an LED on pin12, the script will not get past line27 where pin12 is set high. There is no error message.
How do I structure this script so that Firmata works on each loop? I am interested to learn why the script doesn't work at all but the LED example script will.

Code: [Select]

    import json
   import urllib
   from firmata import *
   from pprint import pprint
   import time
   import serial

   countTweet = 0
   a = Arduino('COM13') #Insert this before the while loop = it never actually works

   while True:
           response = urllib.urlopen('http://search.twitter.com/search.json?q=%23happy&result_type=recent&rpp=1&filter:retweets').read()
       except IOError:
           pprint('no internet connection')
       j = json.loads(response)
       if j['results']:
           text = j['results'][0]['text']
           tID = j['results'][0]['id']
           pprint('bad JSON')
       if countTweet != 0 and lastID != tID:
           pprint('new ID')
           a.pin_mode(12, firmata.OUTPUT)  #Gets stuck here
           a.digital_write(12, firmata.HIGH)
           a.digital_write(12, firmata.LOW)
           pprint('done firmata')
           lastID = tID
           pprint (text)
           pprint ('1')
           pprint("FLC") #First loop complete: To gather the existing tweet before we start
           lastID = tID
           countTweet += 1

Go Up