Skip to content

Commit

Permalink
Update button_event.cpp
Browse files Browse the repository at this point in the history
Add example setup
  • Loading branch information
pjueon authored Jan 12, 2022
1 parent 9483a22 commit b725ba5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion samples/button_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/

/*
EXAMPLE SETUP
Connect a button to pin 11 and GND, a pull-up resistor connecting the button
to 3V3 and an LED connected to pin 7. The application performs the same
function as the button_led.py but performs a blocking wait for the button
press event instead of continuously checking the value of the pin in order to
reduce CPU usage.
*/

#include <signal.h>

#include <chrono>
Expand Down Expand Up @@ -51,7 +60,7 @@ int main()
// Pin Setup.
GPIO::setmode(GPIO::BOARD);

// set pin as an output pin with optional initial state of HIGH
// set pin as an output pin with optional initial state of LOW
GPIO::setup(led_pin, GPIO::OUT, GPIO::LOW);
GPIO::setup(but_pin, GPIO::IN);

Expand Down

0 comments on commit b725ba5

Please sign in to comment.