NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Microcontroller Programming » Using #define

June 18, 2012
by Ralphxyz
Ralphxyz's Avatar

I am having problems using a #define

#define LRSTEP1 ((1<<2) | (1<<3) | (1<<4)

//PORTB = 14;      // Works no complaints!!
PORTB = LRSTEP1;   // Error

 error: expected ')' before ';' token

If I hardcode the value

PORTB = 14;

It works fine.

So how would I use the #define?

This is a continuation of my Stepper Motor Programming thread.


June 18, 2012
by Rick_S
Rick_S's Avatar

You are missing the closing parenthesis in your define line.

June 19, 2012
by Ralphxyz
Ralphxyz's Avatar

Darn, now how the heck did that happen? Must be those Gremlins.

Thanks Rick, it now compiles and even two other errors disappeared.

Now back to my other thread to get the motor to turn.


Post a Reply

Please log in to post a reply.

Did you know that talking to the microcontroller over the USB/Serial link is easy under Windows, Linux, and OS X? Learn more...