Pages: [1]   Go Down
Author Topic: Python Firmata trouble  (Read 288 times)
0 Members and 1 Guest are viewing this topic.
Reading, Berkshire
Offline Offline
Full Member
Karma: 2
Posts: 132
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.

    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('').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

Pages: [1]   Go Up
Jump to: