ESTE: General Purpose Input and Output (GPIO)

De MediaWiki do Campus São José
Ir para: navegação, pesquisa

This experiment is part of this project.

This experiment is based on contents of this UFSC project.

Here we are going to build an experiment with an led and a push button to learn and start using the GPIO. GPIO is called General Purpose Input/Output, and it is basically a group of pins responsable of the communication of input and output digital signals in one board. So the exercise proposed is to turn on and off a led when the push button is pressed or not, respectively.

Pseudo code

Let's begin with a solution. The pseudo code (actual coding is up to you) is below:

int main(void) {
    while(1) {
        if (push_button) {
        else {
    return 0;

This pseudo-code has a comparison statement to see if the push button is pressed (1) or not (0). If yes, the led will turn on and if not (else), the led will stay turned off.


Schematic of the circuit

Part List

  • 2 LED
  • 2 Push buttons
  • 2 10k ohm resistors to the buttons
  • 2 220 ohm resistors to the leds
  • 1 Protoboard
  • 8 copper wires (tinned) or jumpers


Assembly of the circuit



  • AVR GCC and tools
  • Arduino IDE