I am using Android app to control speed of the fan, by using above mentioned code I am using GPIO 24 with frequency 50Hz I want to change fan speed when i change it on Android app on run time I am using sleep function here, fan turns on, on specified speed, but after sleep function executes, it turns off Any suggestions ?
import sys
import time
import RPi.GPIO as GPIO
import psutil
GPIO.setmode(GPIO.BCM)
GPIO.setup(24, GPIO.OUT)
sp= sys.argv[1]
tmp=float(sp)
p = GPIO.PWM(24,50)
p.start(0)
p.ChangeDutyCycle(tmp)
time.sleep(2)
p.stop()