-
Notifications
You must be signed in to change notification settings - Fork 5
Self Locking_Switch_SKU__DFR0423
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.
- Operating Voltage: +3.3-5V
- Output Type: Digital
- Interface Mode: PH2.0-3P
- Dimension: 30*22mm/1.18*0.86 inches
This is a simple test code that will test if the button is pressed or not.
-
Hardware
- UNO x1
- Self-Locking Switch x1
- Jumper Wires
-
Software
- Arduino IDE V1.6.8 Click to Download Arduino IDE from Arduino®
/***************************************************
* 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);
}
}
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.
There are no questions 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.
: shopping from dfrobot store or dfrobot distributor.