Skip to content

Self Locking_Switch_SKU__DFR0423

Angelo edited this page Sep 22, 2016 · 4 revisions

Self-Locking Switch

Introduction

This module is a self locking switch. Press the button to turn it to the "on" state. Press it again to turn it to the "off" state. The board has immersion gold plating and is compatible with the "gravity" 3 pin interface, making it easy to connect to an Arduino I/O expansion shield.

Specification

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

Pinouts

center

Tutorial

This is a simple test code that will test if the button is pressed or not.

Requirements

Wiring Diagram

连线图

Sample Code:

/***************************************************
* Self-Locking Switch
* ****************************************************
* This example lights the LED when the button is pressed

* @author linfeng(490289303@qq.com)
* @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 press the button, the LED connected to pin 13 of the micro controller will turn on; press the button again and the LED will turn off.

FAQ

There are no questions 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.

Clone this wiki locally