Stickc M5stack Change Brightness Of An Led With A Button

Photo of Ron

Made by Ron / Lights / Robotics / Wearables / IoT

About the project

In this project we will learn how to Change the LED Brightness with a Button using a M5StickC ESP32 module. Watch the Video.

Project info

Difficulty: Easy

Platforms: ArduinoVisuinoM5Stack

Estimated time: 1 hour

License: GNU General Public License, version 3 or later (GPL3+)

Items used in this project

Hardware components

M5Stack M5StickC ESP32-PICO Mini IoT Development Board M5Stack M5StickC ESP32-PICO Mini IoT Development Board x 1
LED (generic) LED (generic) x 1

Software apps and online services

Visuino Visuino
Arduino IDE Arduino IDE

Story

In this project we will learn how to Change the LED Brightness with a Button using a M5StickC ESP32 module.

Watch the Video.

Step 1: What You Will Need

1 / 2

Step 2: Circuit

1 / 2

  • Connect LED negative pin to StickC pin GND
  • Connect LED positive pin to StickC pin G0

Step 3: Start Visuino, and Select the M5 Stack Stick C Board Type

1 / 2

Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "M5 Stack Stick C" as shown on Picture 2

Step 4: In Visuino Add & Set Components

1 / 9

  • Add "Counter" component
  • Add "Detect Edge" component
  • Add "Integer To Analog" component
  • Select "Counter1" and in the properties window: set Max>Value to 10,set Min>Value to 0
  • Select "IntegerToAnalog1" and in the properties window set Scale to 0.1

Select "M5 Stack Stick C" board and in the properties window expand Modules>Display ST7735 and: Select Elements and click on the 3 dots button and in the elements

  • drag "Draw Text:" to the left and in the properties window set size to 2 and text to "DIM LED"
  • drag "Text: Field" to the left and in the properties window set size to 3 and Y to 30
  • set Orientation to goRight
  • Close the Elements window
  • Step 5: In Visuino Connect Components

    1 / 3

    • Connect "M5 Stack Stick C" button pin A(M5) to "DetectEdge1" pin In
    • Connect "DetectEdge1" pin Out to "Counter1"pin In
    • Connect "Counter1" pin Out to "IntegerToAnalog1" pin In and "M5 Stack Stick C" >Text Field1> pin In
    • Connect "IntegerToAnalog1" pin Out to "M5 Stack Stick C" to GPIO[0] pin Analog PWM

    Step 6: Generate, Compile, and Upload the Code

    In Visuino, at the bottom click on the "Build" Tab, make sure the correct port is selected, then click on the "Compile/Build and Upload" button.

    Step 7: Play

    If you power the M5StickC module the LED will start to flash and you can change its brightness using a Orange Button M5.

    Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this tutorial, you can download it and open it in Visuino: https://www.visuino.eu

    Schematics, diagrams and documents

    Visuino File

    Code

    Visuino File

    Credits

    Photo of Ron

    Ron

    Arduino Developer

       

    Leave your feedback...