feat: 全量同步 254 个常用的 Arduino 扩展库文件
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "Button2.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
#define BUTTON_A_PIN 2
|
||||
#define BUTTON_B_PIN 0
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
Button2 buttonA = Button2(BUTTON_A_PIN);
|
||||
Button2 buttonB = Button2(BUTTON_B_PIN);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(50);
|
||||
Serial.println("\n\nMultiple Buttons Demo");
|
||||
|
||||
buttonA.setClickHandler(click);
|
||||
buttonB.setClickHandler(click);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void loop() {
|
||||
buttonA.loop();
|
||||
buttonB.loop();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
|
||||
void click(Button2& btn) {
|
||||
if (btn == buttonA) {
|
||||
Serial.println("A clicked");
|
||||
} else if (btn == buttonB) {
|
||||
Serial.println("B clicked");
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
Reference in New Issue
Block a user