NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » counting
January 27, 2011 by Jalex ![]() |
Hi I am having trouble displaying my variables. You can see where I moved the Rain++ out of the while but it still shows 000's.
Here is a clip of the display code. It all inside the while(1) loop
|
---|---|
January 27, 2011 by Jalex ![]() |
It has something to do with inisializing the variables. I chaneged them from uint16_t to double and I seems to work now. I guess I will have to study that some more. |
January 27, 2011 by hevans (NerdKits Staff) ![]() |
Hi Jalex, I think I know what the problem was now. Since you are declaring an integer you need to use %d instead of %f in the format string. Take a look at our tutorial on printf and scanf for more on format strings. Humberto |
January 28, 2011 by Jalex ![]() |
Thanks Humberto That's cool. I guess I have been using Visual Basic too long. LOL Now that it counts there is another problem. Now it won't stop. LOL I have Rain = 0; just before the count code above and it just keeps adding 60 to the count. By the looks of the code it should keep reading 60 if PC3 is high. That Rain++; has been changed to Rain = 0; above the while.... I will studdy your tutorial. Jim |
Please log in to post a reply.
Did you know that you can generate hundreds of volts AC from your microcontroller with a little bit of circuitry? Learn more...
|