0

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()
  • It is NOT so clear what you want to do. In any case, Have you tried to use the statement 'while 1:' in order to continually run a function? – Leos313 Oct 21 '16 at 14:44
  • I tried while 1: But it then stuck into loop, when i change the value of speed from android app, nothing happens, because it is already been stuck into while 1 loop. @Leos313 – Zain Sheikh Oct 22 '16 at 06:25

0 Answers0