StickC M5Stack Change Brightness of an LED With a Button

by RonFrtek in Circuits > Arduino

107 Views, 0 Favorites, 0 Comments

StickC M5Stack Change Brightness of an LED With a Button

StickC M5Stack Change Brightness of an LED With a Button

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

Watch the Video.

What You Will Need

3_a46785e5-1f9e-460b-9796-cc9265ec3fea_1200x1200.jpg
redled.jpg
VisuinoAdvrtisementRaspberryPiRobot1.jpg

Circuit

2020-10-27_17-45-12.jpg
LEDDETAILS-1024x802.jpg

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

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

F5ZAEMUK36U3RS2.LARGE.jpg
FBZIDQ4K36U3RS3.LARGE.jpg

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

In Visuino Add & Set Components

2020-10-27_17-48-59.jpg
2020-10-27_17-48-34.jpg
2020-10-27_17-49-23.jpg
2020-10-27_17-51-26.jpg
2020-10-27_17-53-27.jpg
2020-10-27_17-57-21.jpg
2020-10-27_17-59-29.jpg
2020-10-27_18-02-33.jpg
2020-10-27_18-05-51.jpg
  • 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:
    • set Orientation to goRight
    • 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
  • Close the Elements window

In Visuino Connect Components

2020-10-27_18-08-22.jpg
2020-10-27_18-10-25.jpg
led-dim-stickc.png
  • 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

Generate, Compile, and Upload the Code

2020-10-27_18-20-02.jpg

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.

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 Instructable, you can download it and open it in Visuino: https://www.visuino.eu