LED Button Wiki - DFRobot

Introduction

This is a simple LED-illuminated switch button with a transparent cap. 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! Note: When pressed down, the module output high, and the LED lights up.

Specification

Note: If pressed, this module will output high level and light LED up. If released, it will output low level and light LED out.

Board Overview

Num Silk-screen Description
1 D Control port
2 + VCC
3 - GND

Graphic Programming Tutorial

Connection Diagram

Mind+ Graphic Programming

  1. Download and install the software. Download address: http://mindplus.cc/en.html Detailed tutorial:

  2. Switch to "upload mode". Detailed tutorial:

  3. In "expansion", select "Arduino Uno" in "main controller". Detailed tutorial:

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 released, 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 released, the LED will be off, and the screen will display "×".

Program Effect:

Tutorial for Arduino

Connection Diagram

Requirments

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.

More Documents