#๐Ÿ”’ Need help controlling temperature with a potentiometer

14 messages ยท Page 1 of 1 (latest)

dull quiver
#
import dht
from machine import Pin
from picozero import LED
from time import sleep
from picozero import Pot
class Servo:
    def __init__(self, pin, MIN_DUTY=300000, MAX_DUTY=2300000, freq=50):
        self.pwm = machine.PWM(machine.Pin(pin))
        self.pwm.freq(freq)
        self.MIN_DUTY = MIN_DUTY
        self.MAX_DUTY = MAX_DUTY
    
    def rotate(self, deg):
        if deg < 0:
            deg = 0
        elif deg > 175:
            deg = 175
        duty_ns = int(self.MAX_DUTY - deg * (self.MAX_DUTY-self.MIN_DUTY)/180)
        self.pwm.duty_ns(duty_ns)

servo = Servo(28) #create a new servo on GP 28
dht11 = dht.DHT11(Pin(7))
pot = Pot(26)
temp = 0
humidity = 0

redLED = LED(20)
blueLED = LED(21)
while True:

    pot_value = pot.value

    dht11.measure()
    temp = dht11.temperature()
    humidity = dht11.humidity()
    sleep(2)
    print(f"Temperature: ", temp)
    if temp > 23:
        redLED.on()
        if pot_value < 1/3:
        temp => 25```
last cloudBOT
#

@dull quiver

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

dull quiver
#

Everything works fine besides on my last line im a little confused on how to make it so when i turn my pot my temperature should be equal or greater than 25 which isnt working most likely due to me having the wrong code for the last line,

cedar drift
#

=

dull quiver
#

ty

dull quiver
# cedar drift >=

the temp isnt changing for some reason when i use the pot do u maybe know y?

dull quiver
#

but the value doesnt change when i turn the pot

#

could it be something to do witht he code or maybe my wiring

cedar drift
last cloudBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.

#

๐Ÿ”’ Need help controlling temperature with a potentiometer