Introduction
This is a simple LED-illuminated self-lock switch button. It’s just like a basic switch button, but it lights up color(red / yellow / green / blue / white) when pressed down, which gives you visual feedback. These little buttons can be used with micro:bit to realize various fun interactive projects, such as, switch, backlight keyboard, music player panel, recording control panel, etc.
Specification
- Operating Voltage: +3.3-5V (3.3V is recommended)
- Output: digital
- Connector: PH2.0-3P
- Dimension: 27×26.5mm
- Colors Available: red, yellow, green, blue, white
Note: The module comes with self-lock function. When the button is pressed down, the module outputs High, and the LED lights up. When being pressed again, the module outputs Low and the LED turns off.
Board Overview
Num | Silk-screen | Description |
---|---|---|
1 | D | Control port |
2 | + | VCC |
3 | - | GND |
Graphic Programming Tutorial
Connection Diagram
Mind+ Graphic Programming
- Download and install the software. Download address: http://mindplus.cc/en.html
Switch to "offline mode". Detailed tutorial: https://mindplus.dfrobot.com/microbit
In "expansion", select "Arduino Uno" in "main controller".
Sample Programm
Function Description: When you first press the button, the LED on it will be lighten up, and the micro:bit dot matrix screen will display "√". When you press the button again, the LED will be off, and the screen will display "×".
Program Effect:
MakeCode Graphic Programming
Click link to Basic operation tutorial for MakeCode.
Sample Program
Function Description: When you first press the button, the LED on it will be lighten up, and the micro:bit dot matrix screen will display "√". When you press the button again, the LED will be off, and the screen will display "×".
Program Effect:
Tutorial for Arduino
Connection Diagram
Requirements
- Hardware
- Arduino UNO × 1
- LED Switch Module × 1
- Digital Cable × 1
- Software
Sample Code
/*
Description:
When you press the button for the first time, its inner LED will be lighten up. At the same time, the LED on pin 13 on the board will be lighten up, too.
When you press the button again, its inner LED will be off, and the other one on pin 13 will be off as well.
*/
int ledPin = 13; // Select the pin of light
int inputPin = 2; // Sensor connect pin 2
void setup() {
pinMode(ledPin, OUTPUT); // Define the pin of light as output pin
pinMode(inputPin, INPUT); // Define the pin of button as input pin
}
void loop(){
int val = digitalRead(inputPin); //Read input value
if (val == HIGH) { // Check if the input is high, high means the button is pressed down.
digitalWrite(ledPin, HIGH); // LED light is on
} else {
digitalWrite(ledPin, LOW); // LED light is off
}
}
Program Effect:
FAQ
For any questions, advice or cool ideas to share, please visit the DFRobot Forum.