1479| 4
|
關于如何讓Arduino串口打印一次或者兩次的問題 |
50黑幣
最佳答案bool lastButtonState = HIGH; // 初始假設按鍵未按下(由于使用了PULLUP電阻)
void setup()
{
Serial.begin(19200);
pinMode(3, INPUT_PULLUP); // 使用內部上拉電阻
pinMode(13, OUTPUT);
digitalWrite(13, LOW);
}
void loop()
{
bool currentButtonState = !digitalRead(3); // 按鍵按下時引腳為LOW
if (currentButtonState != lastButtonState) // 檢查按鍵狀態是否改變
{
if (cur ...
| ||
| ||
| ||
| ||
| ||