The Vernier Arduino Interface Shield
includes a general purpose button connected to digital line 12 on the Arduino. You can use this button to control an action in your project. Before this button will work, however, you need to add this line to the setup portion of your sketch:
You read the status of the button with this line of code:
int button = digitalRead(12);
The value of button will be LOW when the button is pressed and HIGH when it is not pressed.
The sample sketch, VernierLibTutorialDCUButtonPress
, will turn on a buzzer connected to DCU
line D1 when the general purpose button on the Vernier Arduino Interface Shield is pressed. The sketch assumes the buzzer is connected to lines D1 and GND on the DCU, and the DCU is plugged into the Digital 2 port on the Vernier Arduino Interface Shield. Note that this sketch will not work with a Digital Protoboard Adapter unless you wire a button to digital line D12 as there is no general purpose button on the adapter.