PulseIn

From Wiring

Jump to: navigation, search


Name pulseIn()
Description The pulseIn() method returns the length in microseconds on a digital input pin for a short period of time from 10 milliseconds to 3 minutes. It can be used to read sensors that return a pulse train like some accelerometers or rangers. The user can specify the counting on HIGH or LOW transitions. The pulseIn command stops all activity while executing. A timeout of 1 second (1000000 microseconds) prevents the command to wait forever. A specific timeout in microseconds can also be specified.
Syntax
pulseIn(pin,transition)
Methods
Constructor
Parameters
pin unknown datatype int: the pin used for reading the pulse
transition unknown datatype HIGH or LOW
timeout unknown datatype int: a timeout value in microseconds
Returns int
Example
int inpin = 8;
int val = 0;
 
void setup() {
  pinMode(inpin, INPUT); 
  Serial.begin(9600);
}
 
void loop() {
  val = pulseIn(inpin, HIGH);
  Serial.println(val);
  delay(100);
}
Related
Language: English
Personal tools