Stephen Covrig / Mbed 2 deprecated Motor Control via PyQt

Dependencies:   mbed

You are viewing an older revision! See the latest version

Homepage

Table of Contents

    Here is the Python Code for the PyQt Gui...

    from PyQt4.QtGui import * from PyQt4.QtCore import * import sys import serial

    def printNumber(number): print number ser = serial.Serial('COM5',9600)

    1. state which port the KL46Z is connected to and the baud rate

    ser.write(unichr(number).encode())

    1. encode number from slider and send the encoded character to KL46Z

    if name=="main": app=QApplication(sys.argv) slider=QSlider(Qt.Horizontal) slider.setRange(1,127) slider.setFixedWidth(400) slider.setSliderPosition(64)

    1. create a QApplication and QSlider

    QObject.connect(slider,SIGNAL("valueChanged(int)"),printNumber)

    1. call the printNumber function each time the value on the slider changes

    slider.show()

    1. start the loop sys.exit(app.exec_())

    All wikipages