Python PyQt Timer Firmata

I am new to python and working with firmata, I am trying to play with arduin.

Here is what I want:

  • Set arduino with LED as digital output
  • Set potentiometer to analog 0

  • Set PyQt timer to update potentiometer position in
    application

  • Set the threshold value in PyQt to turn the LED on (the analog input has 1024 bit resolution, so to say 800 as a threshold value)

I use this firmata library: Link

Here is the code I'm having problems with:

import sys from PyQt4 import QtCore, QtGui from firmata import *

 # Arduino setup
 self.a = Arduino('COM3')
 self.a.pin_mode(13, firmata.OUTPUT)

 # Create timer
    self.appTimer = QtCore.QTimer(self)

    self.appTimer.start(100)
    self.appTimer.event(self.updateAppTimer())


def updateAppTimer(self):
    self.analogPosition = self.a.analog_read(self, 0)
    self.ui.lblPositionValue.setNum()

I get an error message:

Traceback ( ):    "D:\Programming\Eclipse\IO Demo\src\control.py" , 138,     myapp = MainWindow()    "D:\Programming\Eclipse\IO Demo\src\control.py" , 56, init    self.appTimer.event(self.updateAppTimer())    "D:\Programming\Eclipse\IO Demo\src\control.py" , 60, updateAppTimer     self.analogPosition = self.a.analog_read (self, 0) TypeError: analog_read() 2 (3 )

"self", , 1

python, ?

Blockquote

+3
2

"a" , , , , . python, - :)

contra unbound ( , ). :

instance = Type()
#bound method.
instance.methodName(params)

#unbound method call, 'instance' is the instance of some object, pointer to witch
#you want to pass to method. These calls are similar.
Type.methodName(instance, params)
0

. , , .

0

Source: https://habr.com/ru/post/1738571/


All Articles