ARDUINO meets PROCESSING

Pushbutton


navigation

To build the electronic circuit you need the following parts:

The schematic for the circuit looks like this:

scheme for pushbutton circuit

Most pushbuttons have three pins and when the button is pressed the connection between the middle and outer pins is closed. Therefore, we connect 5V to one of the outer pins and the 1kΩ resistor to the middle pin and ground. We will measure 'between' the middle pin and the resistor and therefore have a wire leading from there to pin 7 of the Arduino board. The circuit on your breadboard should look something like this:

picture of pushbutton circuit

If everything is set up right, you can connect the board to the serial (or USB) port of your computer and, if necessary, to the power supply. The power LED should light up and the next step is to export the program which reads the state of the button and sends it to the board. Open the ap_ReadDigital.pde file in Arduino, set the right serial port and baudrate, compile the program, press the reset button on your board and click on the export icon in Arduino to send the program to the board.

To check if everything works fine so far, push the button and check if the control LED lights up. If that's the case, you can now download and unzip pa_PushButton.zip and open the file pa_PushButton.pde in Processing. Again, you will have to set the right serial port, which you do by editing the variable portname. Eventually you might also have to set the correct baudrate by editing its variable (baudrate).

Now, you can run your Processing program. A new window will open and you should see something like this:

If you press the button the value will increase as long as the button is pressed and decrease while it's not.