Question: Create a single program that a) When the P1.1 button is not pushed, no
ID: 3801297 • Letter: Q
Question
Question:
Create a single program that
a) When the P1.1 button is not pushed, nothing happens.
b) When the P1.1 button is pushed, you create a signal like this on the P1.4 pin:
The signal will be Hl for 1.3ms, then it will be LOfor 20ms. The signal will then repeat as long as the button is pushed H- 1.3 ms, HK- 1.3 ms Vdd (5 V) Vss (0 V) L k 20 ms To do this, we are going to use the SMCLK signal inside of the microcontroller instead of the ACLK: 0x0200 I Timer A SMCLK source #define SMCLK The instruction to set the timer up will be: TA0CTL SMC LK I UP Use ACLK, for UP mode The SMCLK increments approximately every lus, so you will need to load appropriate values into the TA0ccRe register.Explanation / Answer
#!/usr/bin/python # -*- coding: utf-8 -*- """ In this example, we connect a signal of a QtGui.QSlider to a slot of a QtGui.QLCDNumber. """ import sys from PyQt4 import QtGui, QtCore class Example(QtGui.QWidget): def __init__(self): super(Example, self).__init__() self.initUI() def initUI(self): lcd = QtGui.QLCDNumber(self) sld = QtGui.QSlider(QtCore.Qt.Horizontal, self) vbox = QtGui.QVBoxLayout() vbox.addWidget(lcd) vbox.addWidget(sld) self.setLayout(vbox) sld.valueChanged.connect(lcd.display) self.setGeometry(300, 300, 250, 150) self.setWindowTitle('Signal & slot') self.show() def main(): app = QtGui.QApplication(sys.argv) ex = Example() sys.exit(app.exec_()) if __name__ == '__main__': main()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.