Maintenance notice: These forum archives are read-only, and will be removed shortly. Please visit our forums at their new location, https://www.evilmadscientist.com/forums/.

Reading the state of Peggy2 tactile switches…

edited July 2013 in LED Matrix Kits
Hi

I poked around these forums, looked at the "Programming Peggy2" article from 2008, and skimmed through the Peggy2.h library but I can't find the answer to my question: how do I read the status of the b1, b2, …, b5 switches on the Peggy2 board? Any and all information greatly appreciated.  Thanks!

Comments

  • The peggy_life.pde program (linked on that page) has a user interface constructed with the buttons, and you can refer to that for an example. 

    Essentially, they are read like any other button inputs on an Arduino (or Arduino compatible) board:  You configure the relevant inputs as inputs with an internal pull-up.  Poll the inputs, and determine if they are high or low.  If the input is low, then the button is currently being pressed.

    The Peggy2_bounce program included with the Peggy library has a simpler example as well, for just a single one of the buttons.   For reference, that button is S2, on AVR pin B0 (aka Arduino pin Digital 8). Buttons b1 through b5 are on AVR pins C0 through C4 (aka Arduino pins Digital 14 through Digital 18).
  • Thanks for the quick reply. I thought the switches would be part of the Peggy2 library, but it makes sense that they're part of the "baseline" Arduino functionality.
Sign In or Register to comment.