Like Tabsoft wrote, you generally want your DEFINEs at the top of the program but it's for readabillity. In reallity it makes no difference because they are not runtime commands.I will drop the pause below the osc value, thanks for that tip
Another little noteWhat's the purpose of setting the LED high inside the loop?Code:for loop1 = 1 to 1000 HIGH LED PAUSE 1 NEXT LOOP1
There's nothing inherently wrong in doing it but it does take (a little) bit of time.
Also, now that you're starting to get the hang of it you might want to consider ditching the HIGH/LOW commands and simply set the pin directly, LED=1, LED=0. For this to work you need to clear the corresponding TRIS-bit first (TRISO.2 = 0 ' Set GPIO.2 to output). Doing it this way executes faster and consumes less codespace since it doesn't waste resources clearing the TRIS bit each and every time (which is what HIGH/LOW does for you).
Again, you're not doing anything "wrong" - it all works fine, I'm just pointing out a couple of things you could improve and take with you to the next project.
/Henrik.




Bookmarks