Last active
December 28, 2019 05:36
-
-
Save choryuidentify/f18a59d158488e97513316d0c086a490 to your computer and use it in GitHub Desktop.
fan_ctrl_manual_opi.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import OPi.GPIO as GPIO | |
import time | |
import sys | |
#import os | |
FAN_PIN = 21 | |
WAIT_TIME = 1 | |
PWM_FREQ = 25 | |
PWM_DUTY = 50 | |
GPIO.setboard(GPIO.PLUS2E) | |
GPIO.setmode(GPIO.BOARD) | |
GPIO.setup(FAN_PIN, GPIO.OUT, initial=GPIO.LOW) | |
fan=GPIO.PWM(FAN_PIN,PWM_FREQ) | |
fan.start(0); | |
i = 0 | |
hyst = 1 | |
tempSteps = [50, 70] | |
speedSteps = [0, 100] | |
cpuTempOld=0 | |
try: | |
while 1: | |
fanSpeed=float(PWM_DUTY) | |
fan.ChangeDutyCycle(fanSpeed) | |
except(KeyboardInterrupt): | |
print("Fan ctrl interrupted by keyboard") | |
GPIO.cleanup() | |
sys.exit() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment