Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1246

Python • Loop in function - read in new data

$
0
0
Hi!

I´ll start of by thanking all the people who have helped me in my earlier questions and encouraging me to read up a bit more. I´m still reading, but now I´m coding and reading ;)

I´ve been trying to read up a bit on python to try to make my first attempt on a more advanced (in neewbie-standards) script and i have stumbled across a problem that i can´t find the answer to.

The setup in short

I´m trying to create (it´s still only on paper) a function (not necessary a def function) where i want to run a few fans for as long as its needed to either;
- reach max time (this is to prevent the fans for running forever in case there is a problem in the code)
- the temperature to decline to either a predefined number or a procentage in relation to the temperature of the air outside
- the humidity to decline acording to the same settings as for temp

The humidity and temperature values are imported from another module and my guess is that is if i make a simple while-loop in the function the values of the temp and hum wont be updated.

Should i make this function in a if statement instead and skip the def function or should i make a def function where I, if its possible, make a "direct import" from the other module into the function so that the values are updated?

I hope this question makes sense, let me know if i should try to further explain something.

Best,

Martin

Statistics: Posted by Martin1234567 — Wed Jan 17, 2024 11:38 pm



Viewing all articles
Browse latest Browse all 1246

Trending Articles