Self Locking_Swicth_SKU__DFR0423 - jimaobian/DFRobotWiki GitHub Wiki

Self-Locking Switch

Introduction

This is a new digital switch module with self-locking function. It could record the status of the button, compatible with DFRobot Gravity 3-Pin interface. Easy to combine with Arduino I/O expansion shield, making very interesting projects. The module is using immersion gold process, safety and non-pollution. Press the button to turn on the LED.

Specification

  • Operating Voltage: +3.3-5V
  • Output Type: Digital
  • Interdface Mode: PH2.0-3P
  • Dimension: 30*22mm/1.18*0.86 inches

Pinout

center

Tutorial

This is a simple test code, to test button pressed or not.

Requirements

The Wiring Diagram

连线图

Sample Code:


/***************************************************
* Self-Locking Swicth
* ****************************************************
* This example light the LED when press the button

* @author linfeng([email protected])
* @version  V1.0
* @date  2016-1-25

* GNU Lesser General Public License.
* See <http://www.gnu.org/licenses/> for details.
* All above must be included in any redistribution
* ****************************************************/


int ledPin = 13;
int inputPin = 4;

void setup() {
  pinMode(ledPin, OUTPUT);
  pinMode(inputPin, INPUT);
}

void loop(){
  int val = digitalRead(inputPin);
  if (val == HIGH) {
    digitalWrite(ledPin, HIGH);
  } else {
    digitalWrite(ledPin, LOW);
  }
}

Results

When you pressed the button , the LED of the pin 13 on the main board is on; Button again, the LED is off.

FAQ

There are no question about this product yet. If you have any problems or suggestions, you are welcome to post on the DFRobot forum.

center For any questions/advice/cool ideas to share, please visit DFRobot Forum.

More

[Schematic] [layout] [SVG file]

:link=http://www.dfrobot.com/ shopping from dfrobot store or dfrobot distributor.