Sale!

2 Pieces 12*12*7.3 Square Button

Original price was: 1,96 €.Current price is: 1,70 €. Excluding VAT

2 Pieces 12*12*7.3 Square Push Button

6 in stock (can be backordered)

Domande su questo prodotto? Scrivi a Lana su WhatsApp

🎬 The product on video

Description

What it is

The two square buttons with dimensions 12x12mm are a simple but essential component for Arduino and Raspberry Pi projects. This type of switch is ideal for implementing features such as turning devices on or off.

Features

  • Dimensions: 12x12mm
  • Height: 7.3mm
  • Quantity: 2 pieces

What it is for

Square buttons are useful for projects that require a simple and visible user interface, such as creating interactive games or turning devices on and off. They are compatible with Arduino and Raspberry Pi.

Tutorial: How to Use Square Button 12*12mm

This square button with dimensions 12x12mm is ideal for Arduino and Raspberry Pi projects that require a simple but visible switch. Ideal for both beginners and experienced makers.

What you need

  • Arduino Uno
  • Connection to GPIO pin
  • Jumper wire

Steps

  1. Connect the button to the microcontroller pins using jumper wires.
  2. Check the polarity of the button contacts: usually one is common (NC or NO) and the other is the command.
  3. Write an Arduino sketch to read the state of the button. Use pinMode() to set the pin as INPUT.
  4. Set a boolean variable to store the current state of the button.
  5. In the loop(), use digitalRead() to check if the button is pressed or released.
  6. Add a command depending on the state of the button (e.g. turn on an LED).
  7. Compile and upload the sketch to the microcontroller.
  8. Test the functionality by pressing the button.

Example code

const int buttonPin = 2; // Pin collegato al pulsante
int lastButtonState = HIGH;
void setup() {
pinMode(buttonPin, INPUT);
}
void loop() {
int reading = digitalRead(buttonPin);
if (reading != lastButtonState) {
lastButtonState = reading;
delay(50); // Attende per evitare il bounce
if (reading == LOW) {
// Il pulsante è premuto
Serial.println("Pulsante premuto");
}
}

Mini project

Create a game projectile that turns on an LED when the player presses the button. Use a second button to release it.

Common mistakes

  • Do not check the polarity of the button contacts.
  • Ignore the button bouncing effect.
  • Use a pull-up resistor without necessity.
  • Connect the button incorrectly to the GPIO pins.

Recommended accessories

  • Arduino Uno
  • 3D Print Case for Arduino
  • Set of RGB LEDs
  • Jumper Wire

Frequently asked questions

How can I avoid the button bounce effect?
Add a delay of about 50ms in your loop() cycle or use a library like Debounce.

Can I connect multiple buttons to a single pin?
Yes, but you will need to manage the logic to distinguish between the different buttons. Consider using a multiplexer if you have many interfaces.

What is the power consumption of the button when it is not pressed?
Check the product datasheet.

Reviews

There are no reviews yet.

Be the first to review “2 Pieces 12*12*7.3 Square Button”

Your email address will not be published. Required fields are marked *