Code Monkey home page Code Monkey logo

arduino-code-snippets's Introduction

arduino-code-snippets

触摸中断模拟点击

一些esp32 arduino的代码片段

  • touch-interrupt
    • 可以模拟单机和长按的触发
    • 功能
      • 判断是否是单机
      • 判断是否是长按

GPIO中断

  • arduino对esp32的gpio中断控制非常简单
  • 函数定义
attachInterrupt(pin, function, mode);
  • 参数详解

    • pin gpio的pin脚值

    • function 当中断触发时调用的函数

    • mode 中断响应的模式

      • CHANGE 边沿触发 只要发生电平变化

      • RISING 上升沿触发 低电平到高电平

      • FALLING 下降沿触发 高电平到低电平

  • 示例代码(arduino)

int pin = 13; // gpio pin脚

void setup()
{
  attachInterrupt(pin, func, CHANGE); // 边沿中断
}

void loop()
{

}

void func()	// 中断处理函数
{
  digitalRead(pin); // 获取gpio的电平值做相应的处理
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.