Arduino - What is a Pulse and How to Use the pulseIn() Function (with example)

preview_player
Показать описание
Everything you need to know about what is a pulse, and how to measure the duration of a pulse with the pulseIn() Arduino function - using an example with a push button.

0:00 Intro
0:20 What is a pulse and how does pulseIn() work?
2:43 Circuit with push button to make the pulseIn() test
3:50 Write the code with pulseIn()
7:01 Test the program to measure duration of a pulse
8:07 Best practices with pulseIn()
10:30 Outro

Рекомендации по теме
Комментарии
Автор

Hi Mr., I want to ask if using interrupt to replace pulsein, does it only read high? How do you read push button low, Mr.? Please, use interrupt to replace pulsein

mubasirkhafid
Автор

My results do not match yours - will you please tell me why
#define buttonPin 2

void setup ()
{
Serial.begin (9600);
pinMode(buttonPin, INPUT);
}
void loop()
{
unsigned long duration = pulseIn(buttonPin, HIGH,
Serial.println (duration);
}

i pressed the button several times : 2sec, 2 sec, 2sec, 6 sec
these results were shown on serial monitor
60
61
41
995942
64
0
42
0
0

lastchance
Автор

i am trying to compile for Attiny402 device, but Arduino gives error " error compiling for board Attiny41/402/212/202"
please advise

subhashkendole
Автор

Thanks for video! I try to do PWM switch (ON/OFF) with pulseIn() function like in your video. But there is no reaction. Could you help me to fix this problem?

Daminski_Elevator
Автор

Good video thanks for making this, very helpful!

SaintNicholas
Автор

Good explanations thank you for teaching 💕

jimmym
Автор

hi would this work if i was to count the pulses that come off a 24 v coin mechanism? My coin mech sends a pulse each time a quarter is deposited?

garymitchell
Автор

why aren't you up the trend of youtube ?
you deserve it bro! keep up :D

thedoctor