NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » First MCU Program
February 10, 2012 by TheUnfocusedOne |
Hi All, I'm currently working through the tutorial, and I decided to do a small side track to test out my programming skills thus far. My goal is a simple program, which will light up one of three LEDs depending on the temperature being read by the temperature sensor. It's a good chance for me to utilize what I've learned from both projects to create a new code. Temp LED combos are as followed: <75 - Green between 75 and 83 - Yellow
Here's my code:
I'm not looking for someone to rewrite my code fyi, it's there incase I'm doing something stupid. I'd rather suggestions and advice than a solution. Thanks in advanced. -TUO |
---|---|
February 10, 2012 by pcbolt |
Hi TUO - There could be a few things going on here. First, just make sure the "libnerdkits" folder is in the same parent folder as your project folder. Second, you listed delay.h twice, and I don't think that would be a problem unless you meant to add some other header file. Third, on line 88 above you call "delay_ms" with no argument. The compiler won't like that. On an unrelated matter, on line 81 you have:
I don't know for certain if this works as intended. I would go with:
Just to be safe. |
February 10, 2012 by dvdsnyd |
Hi TUO, Could you go into a bit more explanation of what isn't working? Not compiling? Or is it just not behaving as you expected? |
February 11, 2012 by TheUnfocusedOne |
Figured it out! Stupid syntax issues, such as trying to make unint_16 variables instead of the correct uint_16. Have it loaded, but it doesn't seem to be working... All the LEDs are on... Back to the drawing board! Thank to you two for the help. PCbolt I took your advice, much better line of code IMO. Is there anyway to edit my first post? I hate how wide it is. |
Please log in to post a reply.
Did you know that you can connect digital calipers to a microcontroller? Learn more...
|