Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] using #define
11-11-2013, 10:36 PM, (This post was last modified: 11-11-2013, 11:40 PM by darby59.)
#1
[SOLVED] using #define
I'm using Pinguino X.4 with PIC18F2550 and have problem with #define. This code was tested with Arduino but give me an error ("Too many parameters" with Pinguino :
//Test define
#define Led 13
#define LedOn digitalWrite(Led, HIGH)
#define LedOff digitalWrite(Led, LOW)

void setup () {
pinMode (Led,OUTPUT) ;
}
void loop () {
LedOn;
delay(500);
LedOff;
delay(500);
}

Thanks for your help.
Yves
Reply
11-11-2013, 11:36 PM,
#2
RE: using #define
The problem is with the name of the function, without upper case letters :
This code is correct :
//Test define
#define Led 13
#define LedOn digitalwrite(Led, HIGH)
#define LedOff digitalwrite(Led, LOW)

void setup () {
pinMode (Led,OUTPUT) ;
}
void loop () {
LedOn;
delay(500);
LedOff;
delay(500);
}
Reply
13-11-2013, 08:05 AM,
#3
RE: [SOLVED] using #define
Thanks for posting the solution!
Reply
13-11-2013, 10:09 AM,
#4
RE: [SOLVED] using #define
The IDE's pre-processor doesn't check #define's content so C expression must be used instead of Pinguino's expression.
If you think it must change, please report this on the issue list.
It is easier to complain than it is to do, but it is better to do than it is to complain.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)