特價

五色大按鈕控制模組 按鍵控制模組

NT$200 NT$175

15 件庫存

貨號: IMD-002047 分類: 標籤: , ,

描述

五色大按鈕控制模組 按鍵控制模組

arduino專用模塊,端口兼容傳感器擴展板
按下時輸出低電平,釋放保持高電平
尺寸:26*21mm
一套套五個(紅、黃、綠、藍、白色各一枚)

 

// Sensor Signal (S) = [Pin 3]
// Sensor +V = [Pin 5V]
// Sensor – = [Pin GND]

// Arduino Code for Push button Module
int Led = 13 ;// Declaration of the LED-output pin
int Key = 3; // Declaration of the sensor input pin
int val; // Temporary variable
  
void setup ()
{
  pinMode (Led, OUTPUT) ; // Initialization output pin
  pinMode (Key, INPUT_PULLUP) ; // Initialization Key pin with internal pull-up resistor
}
  
void loop ()
{
  val = digitalRead (Key) ; // The current signal at the key will be read
  
  if (val == HIGH) // If a signal was detected, the LED will light up.
  {
    digitalWrite (Led, HIGH);
  }
  else
  {
    digitalWrite (Led, LOW);
  }
}