NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Need help with some temperature sensing
June 03, 2012 by chaosatom |
Hi, I am running a motor, which goes faster if I increase the temperature by pinching the temperature sensor. I am trying to check if "Current_Temperature > Original Temperature + 2" to sense the increase in temperature. So initially in while loop, I set temp1 to be original temperature. Then I check if the average temperature has gone over original temperature+2. The problem is that it goes through the if statement instantaneously. What could I do?
|
---|---|
June 03, 2012 by Ralphxyz |
Well at the very least you could put in a delay.
Ralph |
June 03, 2012 by pcbolt |
chaosatom - Your first "if" statement will never execute the code inside the braces. When you write:
You're assigning j the value 0, which evaluates to "false". For a comparison you need a double "=" sign:
The rest looks good. |
June 03, 2012 by chaosatom |
Thanks for the advice guys. I got it to work. That if statement was a problem. Also the time delay code would help me as well. |
June 03, 2012 by pcbolt |
Great. Did you get the PWM output to vary the motor speed? I'm curious which transistors and flyback diodes you decided on and how it was wired. |
June 03, 2012 by chaosatom |
Yes, I decided to go with the 2N7000 transistor. For diode, I had one lying around (not sure about the name). The wiring was done exactly as shown in this tutorial.
http://www.nerdkits.com/videos/motors_and_microcontrollers_101/ I had a separate 9V battery powering this. |
Please log in to post a reply.
Did you know that you can impress a loved one with a digitally-controlled Valentine's Day Card with randomly twinkling LEDs? Learn more...
|