would be Simon game, as a demonstrator for buttons debouncing and \"collecting\" ---
DebounceIn Class Reference
DebounceIn adds mechanical switch debouncing to DigitialIn. More...
#include <DebounceIn_.h>
Public Member Functions | |
void | set_debounce_us (int i) |
set_debounce_us | |
void | set_samples (int i) |
set_samples | |
int | read (void) |
read | |
operator int () | |
operator int() | |
DebounceIn (PinName pin, const char *name=NULL) | |
Constructor. | |
void | set_debounce_us (int i) |
set_debounce_us | |
void | set_samples (int i) |
set_samples | |
int | read (void) |
read | |
operator int () | |
operator int() | |
DebounceIn (PinName pin, const char *name=NULL) | |
Constructor. |
Detailed Description
DebounceIn adds mechanical switch debouncing to DigitialIn.
Example:
#include "mbed.h" #include "DebounceIn.h" DebounceIn d(p5); DigitialOut led1(LED1); DigitialOut led2(LED2); int main() { while(1) { led1 = d; led2 = d.read(); } }
- See also:
- set_debounce_us() To change the sampling frequency.
- set_samples() To alter the number of samples.
This example shows one input displayed by two outputs. The input is debounced by the default 10ms.
Definition at line 54 of file DebounceIn_.h.
Constructor & Destructor Documentation
DebounceIn | ( | PinName | pin, |
const char * | name = NULL |
||
) |
Constructor.
- Parameters:
-
PinName pin The pin to assign as an input.
Definition at line 93 of file DebounceIn_.h.
DebounceIn | ( | PinName | pin, |
const char * | name = NULL |
||
) |
Constructor.
- Parameters:
-
PinName pin The pin to assign as an input.
Definition at line 93 of file DebounceIn__copy.h.
Member Function Documentation
operator int | ( | ) |
operator int()
Read the value of the debounced pin.
Definition at line 85 of file DebounceIn__copy.h.
operator int | ( | ) |
int read | ( | void | ) |
int read | ( | void | ) |
void set_debounce_us | ( | int | i ) |
set_debounce_us
Sets the debounce sample period time in microseconds, default is 1000 (1ms)
- Parameters:
-
int i The debounce sample period time to set.
Definition at line 63 of file DebounceIn__copy.h.
void set_debounce_us | ( | int | i ) |
set_debounce_us
Sets the debounce sample period time in microseconds, default is 1000 (1ms)
- Parameters:
-
int i The debounce sample period time to set.
Definition at line 63 of file DebounceIn_.h.
void set_samples | ( | int | i ) |
set_samples
Defines the number of samples before switching the shadow definition of the pin.
- Parameters:
-
int i The number of samples.
Definition at line 72 of file DebounceIn_.h.
void set_samples | ( | int | i ) |
set_samples
Defines the number of samples before switching the shadow definition of the pin.
- Parameters:
-
int i The number of samples.
Definition at line 72 of file DebounceIn__copy.h.
Generated on Sun Sep 11 2022 18:35:40 by 1.7.2