Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
(SOLVED)[Library] Only one pulseIn() constructor recognized ?
02-11-2013, 11:00 PM, (This post was last modified: 03-11-2013, 02:13 PM by FlacoDev.)
(SOLVED)[Library] Only one pulseIn() constructor recognized ?
Hi guys,

I have a little problem with the function pulseIn().

On the pulseIn() page in the Arduino language's documentation we can see that pulseIn() has two constructor: pulseIn(pin, value) and pulseIn(pin, value, timeout), where timeout is, in fact, an optional parameter.

so, when I do (for example):

... (some definitions)
#define echoPin 6

long duration;

   pinMode(echoPin, INPUT);

   duration = pulseIn(echoPin, HIGH);

It will not work; I must write : duration = pulseIn(echoPin, HIGH, 1000)

I know, it's no big deal, but I just wanted to note that. ^^

Sorry if this thread is in the wrong section.

03-11-2013, 11:14 AM,
RE: [Library] Only one pulseIn() constructor recognized ?
Arduino uses C++ and Pinguino uses C.
C doesn't allow optional argument. The only way would be to declare each function as a varargs function. Not sure it's a good idea.
This is one of the reason why Pinguino will never be 100% compatible with Arduino.
It is easier to complain than it is to do, but it is better to do than it is to complain.
03-11-2013, 02:12 PM,
RE: [Library] Only one pulseIn() constructor recognized ?
Smile Okay; I see!
Thank you regis!

Forum Jump:

Users browsing this thread: 1 Guest(s)