Skip to content

Instantly share code, notes, and snippets.

@choryuidentify
Last active December 28, 2019 05:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save choryuidentify/f18a59d158488e97513316d0c086a490 to your computer and use it in GitHub Desktop.
Save choryuidentify/f18a59d158488e97513316d0c086a490 to your computer and use it in GitHub Desktop.
fan_ctrl_manual_opi.py
#!/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