Step 1: Get the IDE |
|
The Antipasto Arduino branch of the Arduino IDE has the ButtonShield hardware libraries baked in, and it's available for Mac, Windows, and Linux over at the "App Store". |
|
Here's the Windows version
|
|
Step 2: Install the IDE
Launch the installer (after Firefox checks to make sure there aren't any viruses or spamware, which there aren't but just in case). And just save to the default location (please) because the installer's technically not that smart, and likes to just be saved to the default specified place. |
|
Step 3: Launch the Antipasto Arduino IDE |
|
Step 4: Create a New Gadget |
|
Like this: |
|
|
|
This sets all the source code you need in order to program the Arduino. It also pops up a standard template program including loop() and setup(). | |
Step 6: Copy and paste the Hello World ButtonShield Code |
|
|
|
This code includes the ButtonShield header which includes all the communication primitives you need. Then it defines a variable, ButtonShield buttons, so that you can use the variable buttons anywhere else in the code. Of course Serial.begin sets up a serial communication between the Arduino and the computer. And the piece-de-resistance (haw haw hawww in French) is: Serial.println(buttons.readButtons()). Really that's just trying to be clever on one line. First it's calling: |
|
buttons.readButtons() |
|
which is the magic function. It will read whatever is being pressed on the ButtonShield keyboard at the current time. Then, it encases it in: |
|
Serial.println() |
|
which is the function that sends the number back up to the computer to be displayed. | |
|
|
Step 7: Compile the Code |
|
Step 8: Put the ButtonShield on the Arduino |
|
|
|
Action shot - slow-mo cut sequence: |
|
|
|
This is the ButtonShield and Arduino, happily reunited: |
|
|
|
Step 9: Connect the USB cable from the Arduino to the computer |
|
Step 10: Set the USB port in the Tools->Serial Port menu |
|
|
|
Step 11: Upload the Program to the Arduino |
|
|
|
Step 13: Use this code if you have a ButtonPad |
|
#include |