DFR0423 Gravity: Digital Self-Locking Switch


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.



DFR0423 Gravity: Digital Self-Locking Switch Pinout


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


The Wiring Diagram

DFR0423 Gravity: Digital Self-Locking Switch The Wiring Diagram

Sample Code:

 * @file  selfLockingSwitch.ino
 * @brief  This example light the LED when press the button.
 * @copyright  Copyright (c) 2010 DFRobot Co.Ltd (
 * @license  The MIT License (MIT)
 * @author  linfeng(
 * @version  V1.0
 * @date  2016-6-21

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);


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


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

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

More Documentation