📈
Ween's Lab
UdemyYouTubeTikTok
  • Welcome
  • 📻FPGA Tutorials
    • FPGA Boards: Getting Started
      • Getting Started with PYNQ on Kria KV260 Vision AI Starter Kit
      • Getting Started with PYNQ on Red Pitaya STEMlab 125-14
      • Getting Started with PYNQ on ZYBO
    • FPGA Ethernet Tutorial
      • FPGA Tutorial Ethernet 1: Simple TCP Server
    • PYNQ FPGA Tutorial 101
      • Part 0: Introduction
      • Part 1: GPIO
      • Part 2: Custom IP
      • Part 3: Memory
      • Part 4: ANN Processor
    • PYNQ FPGA Tutorial 102
      • Part 0: Introduction
      • Part 1: Memory Mapped
      • Part 2: Direct Memory Access
      • Part 3: AXI-Lite Multiplier
      • Part 4: AXI-Stream Multiplier with DMA
      • Part 5: AXI-Lite GCD
      • Part 6: AXI-Stream GCD with DMA
      • Part 7: Access to DDR from PL
    • ZYNQ FPGA Tutorial
      • Part 1: Gate-Level Combinational Circuit
      • Part 2: RT-Level Combinational Circuit
      • Part 3: Regular Sequential Circuit
      • Part 4: FSM Sequential Circuit
      • Part 5: ZYNQ Architecture
      • Part 6: ARM CPU and FPGA Module
      • Part 7: FPGA Memory
      • Part 8: Hardware Accelerator for Neural Networks
    • ZYNQ FPGA Linux Kernel Module
      • Cross Compiling Kernel, Kernel Module, and User Program for PYNQ
      • Configure PL to PS Interrupt in Kernel Module
      • Configure AXI DMA in Kernel Module
  • 📟Proyek Arduino
    • Kumpulan Proyek
      • Rangkaian LED
      • LED Berkedip Nyala Api
      • LED Chaser
      • LED Binary Counter
      • OLED 128x4 Bitcoin Ticker
      • Rangkaian Button
      • Button Multifungsi
      • Button Interrupt
      • Button Debouncing
    • Pelatihan Mikrokontroler Arduino ESP32
      • Bab 1 Pengenalan Mikrokontroler
      • Bab 2 Pengenalan Arduino
      • Bab 3 Pengenalan Bahasa C
      • Bab 4 Digital Output
      • Bab 5 Digital Input
      • Bab 6 Serial Communication
      • Bab 7 Analog-to-Digital Conversion
      • Bab 8 Interrupt
      • Bab 9 Timer
      • Bab 10 Pulse-Width Modulation
      • Bab 11 SPI Communication
      • Bab 12 I2C Communication
  • 💰Finance
    • Coding for Finance
      • Build a Bitcoin Price Alert with Google Cloud and Telegram
      • Build a Bitcoin Ticker with ESP32 and Arduino
      • Stock Price Forecasting with LSTM
    • Trading dan Investasi
      • Istilah Ekonomi, Keuangan, Bisnis, Trading, dan Investasi
      • Jalan Menuju Financial Abundance
      • Memahami Korelasi Emas, Oil, Dollar, BTC, Bonds, dan Saham
      • Mindset Trading dan Investasi
      • Rangkuman Buku: Rahasia Analisis Fundamental Saham
      • Rangkuman Buku: The Psychology of Money
      • Rangkuman Kuliah: Introduction to Adaptive Markets
      • Rumus Menjadi Orang Kaya
  • 📝Life
    • Life Quotes
Powered by GitBook
On this page
  • Penjelasan Proyek
  • Daftar Komponen
  • Rangkaian
  • Library
  • Kode Program
  • Hasil
  1. Proyek Arduino
  2. Kumpulan Proyek

Button Multifungsi

PreviousRangkaian ButtonNextButton Interrupt

Last updated 12 months ago

Penjelasan Proyek

Pada proyek ini, kita akan membuat tombol multifungsi dengan satu button.

Daftar Komponen

Komponen yang diperlukan yaitu sebagai berikut:

  • Board ESP32

  • Breadboard

  • Push button

Rangkaian

Rangkaian yang dibuat yaitu sebagai berikut. Button dirangkai dengan konfigurasi rangkaian active-low dengan internal pull-up resistor pada pin GPIO 23.

Library

Untuk membuat proyek ini diperlukan library berikut ini:

Kode Program

Kode program yang dibuat yaitu sebagai berikut. Program akan melakukan instansiasi kelas OneButton menjadi objek button. Setelah itu, pada bagian fungsi setup(), button akan dihubungkan dengan beberapa fungsi:

  • Fungsi buttonClick() akan dipanggil ketika button ditekan satu kali

  • Fungsi buttonDoubleClick() akan dipanggil ketika button ditekan dua kali.

  • Fungsi buttonMultiClick() akan dipanggil ketika button ditekan lebih dari dua kali.

  • Fungi buttonLongPressStop() akan dipanggil ketika button selesai ditekan dengan durasi yang lebih lama.

button_events_serial.ino
#include "OneButton.h"

// Button on pin 23, active-low
OneButton button(23, true);

void setup()
{
  Serial.begin(9600);
  button.attachClick(buttonClick);
  button.attachDoubleClick(buttonDoubleClick);
  button.attachMultiClick(buttonMultiClick);
  button.attachLongPressStop(buttonLongPress);
}

void loop()
{
  button.tick();
  delay(10);
}

void buttonClick()
{
  Serial.println("Button click.");
}

void buttonDoubleClick()
{
  Serial.println("Button double click.");
}

void buttonMultiClick()
{
  Serial.println("Button multi click.");
}

void buttonLongPress()
{
  Serial.println("Button long press.");
}

Hasil

Hasil dari proyek ini yaitu pada gambar berikut ini.

📟
GitHub - mathertel/OneButton: An Arduino library for using a single button for multiple purpose input.GitHub
proyek_arduino/button/button_events_serial/button_events_serial.ino at main · weenslab/proyek_arduinoGitHub
Logo
Logo