NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » #define BUT_UP PORTB5
June 16, 2010 by n3ueaEMTP |
Quick Question & I think I know the answer but I want to make sure. Does #define BUT_UP PORTB5 mean that I can use BUT_UP in place of PB5 in if statements? For Example, when using the #define statement is:
the same as
Thanks in advance for an help. Chris B. n3ueaEMTP |
---|---|
June 16, 2010 by hevans (NerdKits Staff) |
Hi Chris, I think the answer to your question is yes. The #define is a preprocessor directive. Which means that if I do
It will take your C code and replace all occurrences of FOO in your code with bar, literally without interpreting either FOO or bar. Your example is not quite right because you said #define BUT_UP PORTB5, but I think you meant #define BUT_UP PB5, which would be correct. Humberto |
June 16, 2010 by n3ueaEMTP |
Humberto, thanks for the information. I "borrowed" that code from the internet for a project. I decided to repalce the BUT_UP with PC5. That's what is in the NK guidebook so I just stuck with what I know. Thanks for the response! Chris B |
Please log in to post a reply.
Did you know that essentially all power supplies' voltages drop when current is drawn from them? Learn more...
|