Shake the Dice Using Atom Matrix ESP32

In this Tutorial we are going to make an Electronic Dice that will display a different number every time you shake the Atom Matrix ESP32. The project is based on a built-in accelerometer where we detect the force of the movement.

Watch the video!

STEP 1
What You Will Need

 

What You Will Need

What You Will Need photo 2

STEP 2
Start Visuino, and Select the Atom Matrix Board Type

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 "Atom Matrix" as shown on Picture 2

Start Visuino, and Select the Atom Matrix Board Type

Start Visuino, and Select the Atom Matrix Board Type photo 2

STEP 3
In Visuino Add Components
  • Add "Absolute Analog Value" component
  • Add "Compare Analog Value" component
  • Add "Timer" component
  • Add "Clock Generator" component
  • Add "Random Integer Generator" component
  • Add "Integer Multi Source" component
  • Add "Acceleration To 3D Angle and Force" component

In Visuino Add Components

In Visuino Add Components photo 2

In Visuino Add Components photo 3

In Visuino Add Components photo 4

In Visuino Add Components photo 5

In Visuino Add Components photo 6

In Visuino Add Components photo 7

STEP 4
In Visuino Set Components
  • Select "M5 Stack ATOM Matrix" board and in the properties window expand "Modules">"RGB Matrix">"Elements" and click on the 3 dots button
  • In the "Elements" window drag "Fill Screen" to the left side
  • In the "Elements" window drag "Text Field" to the left side, and in the properties window set "Color" to aclRed and "X" to 1, select "Elements" and click on the 3 dots button, In the "Elements" window drag "Font" to the left side and in the properties window set "Font" to Adafruit\Picopixel
  • Close both "Elements" window

 

  • Select "CompareValue1" and in the properties window set "Compare Type" to ctBigger and "Value" to 1.7
  • Select "Timer1" and in the properties window set "Interval (uS)" to 2000000
  • Select "RandomIntegerGenerator1" and in the properties window set "Max" to 6 and "Min" to 1
  • Select "IntegerMultiSource1" and in the properties window set "Output Pins" to 3
  • Select "ClockGenerator1" and in the properties window set "Frequency" to 20
  • Select "ClockGenerator1" and in the properties window select "Enabled" & click on the pin Icon and select "Boolean SinkPin"

 

In Visuino Set Components

In Visuino Set Components photo 2

In Visuino Set Components photo 3

In Visuino Set Components photo 4

In Visuino Set Components photo 5

In Visuino Set Components photo 6

In Visuino Set Components photo 7

In Visuino Set Components photo 8

In Visuino Set Components photo 9

In Visuino Set Components photo 10

STEP 5
In Visuino Connect Components
  • Connect M5 Stack ATOM Matrix > Accelerometer pin [X] to "AccelerationToAngle1" pin [X]
  • Connect M5 Stack ATOM Matrix > Accelerometer pin [Y] to "AccelerationToAngle1" pin [Y]
  • Connect M5 Stack ATOM Matrix > Accelerometer pin [Z] to "AccelerationToAngle1" pin [Z]
  • Connect "AccelerationToAngle1" pin [Force] to Abs1" pin [In]
  • Connect "Abs1" pin [Out] to CompareValue1" pin [In]
  • Connect "CompareValue1" pin [Out] to "Timer1" pin [Start]
  • Connect "Timer1" pin [Out] to "ClockGenerator1" pin [Enabled]
  • Connect "ClockGenerator1" pin [Out] to "RandomIntegerGenerator1" pin [In]
  • Connect "RandomIntegerGenerator1" pin [Out] to "IntegerMultiSource1" pin [In]
  • Connect "IntegerMultiSource1" pin [0] to "M5 Stack ATOM Matrix" > "Fill Screen1" pin [Clock]
  • Connect "IntegerMultiSource1" pin [1] to "M5 Stack ATOM Matrix" > "Text Field1" pin [In]
  • Connect "IntegerMultiSource1" pin [2] to "M5 Stack ATOM Matrix" > "Text Field1" pin [Clock]

In Visuino Connect Components

In Visuino Connect Components photo 2

STEP 6
Generate, Compile, and Upload the Arduino 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.

Generate, Compile, and Upload the Arduino Code

STEP 7
Play

If you power the ATOM Matrix module and shake it the Display will start to show a random number from 1 to 6.

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

icon Atom-Matrix-ESP32-dice.zip 14KB Download(0)
License
All Rights
Reserved
licensBg
0