On a Pico with v1.91 I can do digitalPulse(B3, 1, 0.10, 0.1) to get a short pulse of 0.1ms length, with the pin returning to 0 at the end. I'm expecting the same for digitalPulse(B3, 1, [0.1, 0.1]).
However, when passing the lengths as array the pin state is finally 1.
What am I missing here?
digitalPulse(B3, 1, 0.10, 0.1)
digitalPulse(B3, 1, [0.1, 0.1])
digitalPulse only takes 3 arguments, so with digitalPulse(B3, 1, 0.10, 0.1) the final argument is ignored - it's like saying digitalPulse(B3, 1, 0.10)
digitalPulse(B3, 1, 0.10)
When you pass an array, you're passing [on,off,on,off,... - so if you pass an odd number of arguments the pin will return to its initial state (in your case 0), but if you pass an even number of arguments it'll finish at 1 - does that help?
Definitely, yes. Thanks for the explanation :)
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem