Shop OBEX P1 Docs P2 Docs Learn Events
Simple "count" question — Parallax Forums

Simple "count" question

Beavis3215Beavis3215 Posts: 229
edited 2018-09-10 16:12 in Learn with BlocklyProp
long count	(	int 	pin,
long 	duration 
)		
Count number of low to high transitions an external input applies to an I/O pin over a certain period of time.

Parameters
pin	I/O pin number
duration	Amount of time the measurement counts transitions
Returns
The number of low to high transitions



This is out of the propeller.h manual.
Does anyone know the default units of "a certain period of time"?
I am assuming milliseconds, as most of the other examples of timing commands use milliseconds.

Suppose that pin 19 is already an input, and is being used elsewhere in the program. Would int t = count(19, 1000) and the other function of pin 19 be possible at the same time?

Comments

  • Milliseconds would be correct.

    "Suppose that pin 19 is already an input, and is being used elsewhere in the program. Would int t = count(19, 1000) and the other function of pin 19 be possible at the same time?"
    Not in the same cog, since the count() function will run for the specified duration. Make int t global and use count() in a different cog.
Sign In or Register to comment.