Rename library & repository from Button to JC_Button.
This commit is contained in:
34
README.md
34
README.md
@@ -1,20 +1,12 @@
|
||||
# Arduino Button Library v1.0
|
||||
https://github.com/JChristensen/Button
|
||||
ReadMe file
|
||||
Jack Christensen Mar 2012
|
||||
# Arduino Button Library
|
||||
https://github.com/JChristensen/JC_Button
|
||||
README file
|
||||
|
||||

|
||||
|
||||
## Introduction
|
||||
The Button library is for debouncing and reading momentary contact switches like tactile button switches. "Long presses" of arbitrary length can be detected. Works well in state machine constructs. Use the read() function to read each button in the main loop, which should execute as fast as possible.
|
||||
|
||||
## Installation
|
||||
To use the **Button** library:
|
||||
- Go to https://github.com/JChristensen/Button, click the **Download ZIP** button and save the ZIP file to a convenient location on your PC.
|
||||
- Uncompress the downloaded file. This will result in a folder containing all the files for the library, that has a name that includes the branch name, usually **Button-master**.
|
||||
- Rename the folder to just **Button**.
|
||||
- Copy the renamed folder to the Arduino sketchbook\libraries folder.
|
||||
|
||||
## Examples
|
||||
The following example sketches are included with the **Button** library:
|
||||
|
||||
@@ -22,7 +14,7 @@ The following example sketches are included with the **Button** library:
|
||||
- **LongPress**: Demonstrates detecting long and short button presses.
|
||||
- **UpDown**: Counts up or down, one number at a time or rapidly by holding the button down.
|
||||
|
||||
## Button library methods
|
||||
## Button library functions
|
||||
|
||||
### Button(pin, puEnable, invert, dbTime)
|
||||
##### Description
|
||||
@@ -41,7 +33,7 @@ None.
|
||||
Button myButton = Button(2, true, true, 25); //25 ms debounce
|
||||
```
|
||||
|
||||
### read(void)
|
||||
### read()
|
||||
##### Description
|
||||
Reads the button and returns a *boolean* value (*true* or *false*) to indicate whether the button is pressed. The read() function needs to execute very frequently in order for the sketch to be responsive. A good place for read() is at the top of loop(). Often, the return value from read() will not be needed if the other functions below are used.
|
||||
##### Syntax
|
||||
@@ -55,12 +47,12 @@ None.
|
||||
myButton.read();
|
||||
```
|
||||
|
||||
### isPressed(void)
|
||||
### isReleased(void)
|
||||
### isPressed()
|
||||
### isReleased()
|
||||
##### Description
|
||||
These methods check the button state at the point in time when it was last read, and return false or true accordingly. These functions **do not** cause the button to be read.
|
||||
##### Syntax
|
||||
`myButton.isPressed();`
|
||||
`myButton.isPressed();`
|
||||
`myButton.isReleased();`
|
||||
##### Parameters
|
||||
None.
|
||||
@@ -76,12 +68,12 @@ else {
|
||||
}
|
||||
```
|
||||
|
||||
### wasPressed(void)
|
||||
### wasReleased(void)
|
||||
### wasPressed()
|
||||
### wasReleased()
|
||||
##### Description
|
||||
These methods check the button state to see if it changed between the last two reads and return false or true accordingly. These functions **do not** cause the button to be read. Note that these functions may be more useful than `isPressed()` and `isReleased()` since they actually detect a **change** in the state of the button, which is usually what we want in order to cause some action.
|
||||
##### Syntax
|
||||
`myButton.wasPressed();`
|
||||
`myButton.wasPressed();`
|
||||
`myButton.wasReleased();`
|
||||
##### Parameters
|
||||
None.
|
||||
@@ -97,7 +89,7 @@ if ( myButton.wasPressed() ) { ...
|
||||
##### Description
|
||||
These methods check to see if the button is pressed (or released), and has been in that state for the specified time in milliseconds. Returns false or true accordingly. These functions are useful to detect "long presses". Note that these functions **do not** cause the button to be read.
|
||||
##### Syntax
|
||||
`myButton.pressedFor(ms);`
|
||||
`myButton.pressedFor(ms);`
|
||||
`myButton.releasedFor(ms);`
|
||||
##### Parameters
|
||||
**ms:** The number of milliseconds *(unsigned long)*
|
||||
@@ -108,7 +100,7 @@ These methods check to see if the button is pressed (or released), and has been
|
||||
if ( myButton.pressedFor(1000) ) { //has the button been pressed for one second?
|
||||
```
|
||||
|
||||
### lastChange(void)
|
||||
### lastChange()
|
||||
##### Description
|
||||
Under certain circumstances, it may be useful to know when a button last changed state. lastChange() returns the time the button last changed state, in milliseconds (the value is derived from the Arduino millis() function).
|
||||
##### Syntax
|
||||
|
||||
Reference in New Issue
Block a user