I have the following code which will start after clicking the 'Start' button in PyQt:
def Start(self):
import time
import os
import RPi.GPIO as GPIO
import datetime
GPIO.setmode(GPIO.BCM)
DEBUG = 1
os.system('clear')
# SPI port on GPIO
SPICLK = 18
SPIMISO = 23
SPICS = 25
# set up the SPI interface pins
GPIO.setup(SPIMISO, GPIO.IN)
GPIO.setup(SPICLK, GPIO.OUT)
GPIO.setup(SPICS, GPIO.OUT)
GPIO.output(SPICS, True)
GPIO.output(SPICS, False) # bring CS low
while True:
adcout = 0
read_adc = 0
#s=time.clock()
for i in range(25):
GPIO.output(SPICLK, True)
GPIO.output(SPICLK, False)
adcout <<= 1
if (GPIO.input(SPIMISO)==1):
adcout |= 0x1
time.sleep(0.085)
if (GPIO.input(SPIMISO)==0):
read_adc = adcout
millivolts = read_adc * ( 2500.0 /(pow(2,22)))
read_adc = "%d" % read_adc
millivolts = "%d" % millivolts
if DEBUG:
print millivolts, "mV (ADC)"
The above program is for ADC reading and it will start after clicking the pushbutton called 'Start' as : self.pushButton.clicked.connect( self.Start)
And I have another pushButton_2
called 'Stop' and by clicking this the above process should stop.Please suggest, so I can able to do that.