Martha MigliacioAlex Wong
Published © GPL3+

Using the Pmod BTN with Arduino Uno

Application notes for Pmod BTN and Arduino Uno. In this app, the state of the pushbutton will be shown in the serial monitor.

BeginnerProtip1 hour401
Using the Pmod BTN with Arduino Uno

Things used in this project

Story

Read more

Schematics

Pmod BTN and Arduino Uno Fritzing file

Fritzing file displaying the connection of the Pmod BTN to the Arduino Uno.

Pmod BTN and Arduino Uno Fritzing Image

Fritzing image displaying the connection between the Pmod BTN and Arduino Uno.

Code

Pmod BTN and Arduino Uno Code

Arduino
Using this code will show the state of the pushbutton in the serial monitor.
*************************************************************************
* Description: Pmod_BTN
* The state of the push button will be show in the serial monitor.
*
* Material
* 1. Arduino Uno
* 2. Module Pmod BTN
*
************************************************************************/

boolean bp;
int index=0;
void setup()
{
Serial.begin(9600); // initialization of the serial monitor
for (int i=2; i<=5; i++) // configuration pins 2 to 5 in input
{
pinMode(i,INPUT);
 }
}

void loop()
{
for(int i=2; i<=5; i++) // read state of push buttons
 {
bp=digitalRead(i);
delay(40); // Debounce
if(bp==HIGH)
  {
Serial.print("Le bouton BTN");
index=i-2; // index calculation push buton
Serial.print(index);
Serial.println(" est actif.");
  }
 }
}

Credits

Martha Migliacio

Martha Migliacio

5 projects • 12 followers
Alex Wong

Alex Wong

5 projects • 26 followers
I work in Digilent and like creating projects
Thanks to Lextronics.

Comments