i want to control temperature in a small greenhouse. I have a proper sensor ordered, but in the meantime, i have been hacking around with a simple resistor/thermistor string between 3.3v and ground. I can sense the voltage on ADC1, print it, and blink an led once a second.
I have been trying use an " if ADC is > do something" "else if ADC is < do something" where "do something" is turn a pin on or off, etc
I have used every iteration "while" " if > ,if < " that i can think of. I have run out of ideas.
If anybody could point me to a code snippet that will help me get this done, i will be most appreciative.
Sense a voltage and turn on a pin
Re: Sense a voltage and turn on a pin
I'd highly recommend that you take a free python course. I think the gist of what you're looking for is along these lines:
This web page has lots of examples: https://docs.python.org/3/tutorial/index.html
If you want something a bit more structured like a course, then this udacity course is reasonable:
https://www.udacity.com/course/intro-to ... nce--cs101
Code: Select all
while True:
adc_value = read_adc_value()
if adc_value > upper_threshold:
set_gpio_high()
elsif adc_value < lower_threshold:
set_gpio_low()
If you want something a bit more structured like a course, then this udacity course is reasonable:
https://www.udacity.com/course/intro-to ... nce--cs101
-
- Posts: 19
- Joined: Thu Jun 25, 2015 1:04 am
Re: Sense a voltage and turn on a pin
thanks Dave,
I have been looking for a course that is "beginner " enough for me. I was going thru a course from Code Academy, I think it was, but it disappeared! I'll have to get more serious looking for it...
In your code you referenced "elsif". Did you mean "elif"?
I have been looking for a course that is "beginner " enough for me. I was going thru a course from Code Academy, I think it was, but it disappeared! I'll have to get more serious looking for it...
In your code you referenced "elsif". Did you mean "elif"?
Re: Sense a voltage and turn on a pin
Yeah - I work in a bunch of different programming languages on a more or less daily basis, so sometimes I get things confused.Ridley Walker wrote:In your code you referenced "elsif". Did you mean "elif"?
-
- Posts: 19
- Joined: Thu Jun 25, 2015 1:04 am
Re: Sense a voltage and turn on a pin
Confused? Confused!!! You have no idea.
Imagine me at 76 yrs old, can't remember what i had for breakfast, zero experience with this stuff.
Thanks again, your code fixed me right up. I used your code to show me the errors in the stuff i had cobbled up.
Now a happy camper - my greenhouse will be warm this winter...
Imagine me at 76 yrs old, can't remember what i had for breakfast, zero experience with this stuff.
Thanks again, your code fixed me right up. I used your code to show me the errors in the stuff i had cobbled up.
Now a happy camper - my greenhouse will be warm this winter...
-
- Posts: 11
- Joined: Sun May 08, 2016 3:41 pm
Re: Sense a voltage and turn on a pin
and you also need to know about "PID"control.