Skip to content

Instantly share code, notes, and snippets.

@choryuidentify
Created December 28, 2019 05:00
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/b037b7af1c981472f7f63811d1762036 to your computer and use it in GitHub Desktop.
Save choryuidentify/b037b7af1c981472f7f63811d1762036 to your computer and use it in GitHub Desktop.
calib_fan_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
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(input("Fan Speed: "))
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