Arduino Lotto Random Number Generator

About the project

In this tutorial we will LEARN how to generate a random Lotto numbers, using Arduino and Visuino program, and display it on the OLED Display

Project info

Difficulty: Easy

Platforms: ArduinoVisuino

Estimated time: 1 hour

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

Items used in this project

Hardware components

Breadboard (generic) Breadboard (generic) x 1
Jumper wires (generic) Jumper wires (generic) x 1
Resistor 1k ohm Resistor 1k ohm x 1
Button Button x 1
ElectroPeak 0.96" OLED 64x128 Display Module ElectroPeak 0.96" OLED 64x128 Display Module x 1
Arduino UNO Arduino UNO x 1

Software apps and online services

Visuino Visuino
Arduino IDE Arduino IDE

Story

In this tutorial we will LEARN how to generate a random Lotto numbers, using Arduino and Visuino program, and display it on the OLED Display.Arduino will each time, generate a 6 random numbers from 1 to 50.

Watch the video.

Step 1: What You Will Need

1 / 5

  • Arduino UNO (or any other Arduino)
  • OLED Display (SPI)
  • 1K ohm resistor
  • A button
  • Breadboard
  • Jumper wires
  • Visuino program: Download Visuino

Step 2: The Circuit

  • Connect OLED Display pin [SCL] to Arduino pin [SCL]
  • Connect OLED Display pin [SDA] to Arduino pin [SDA]
  • Connect OLED Display pin [VCC] to Arduino pin [5v]
  • Connect OLED Display pin [GND] to Arduino pin [GND]
  • Connect Arduino Digital pin [7] to breadboard pin [GND] and to the Resistor
  • Connect other side of the resistor to the breadboard pin [GND]
  • Connect Other pin of the button to the breadboard positive pin [5V]
  • Connect Arduino pin [5V] to breadboard positive pin [Red line]
  • Connect Arduino pin [GND] to breadboard negative pin [Black line]

Step 3: Start Visuino, and Select the Arduino UNO 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 "Arduino UNO" as shown on Picture 2

Step 4: In Visuino Add Components

1 / 7

  • Add "Clock Generator" component
  • Add "Debounce Button" component
  • Add "Counter" component
  • Add "Random Integer Generator" component
  • Add "Integer Demux" component
  • Add "Formatted Text" component
  • Add "OLED" component

Step 5: In Visuino Set Components

1 / 7

Select "Counter1" and in the Properties window set Max>Value to 6 <<This is the amount of the generated numbers, you can change it if your Lotto system contains less or more numbers. Select "RandomIntegerGenerator1" and in the properties window set Min to 1 and Max to 50 << 50 is the amount of the numbers used in the Lotto, you can adjust this number according to your Lotto system Select "IntegerDemux1" and in the properties window set Output Pins to 6 <<This is the amount of the generated numbers, you can change it if your Lotto system contains less or more numbers.

  • Also set set Max>RollOver to False
  • Select "FormattedText1" and in the properties window set Text to: %0 %1 %2 %3 %4 %5
  • Double click on the "FormattedText1" and in the Elements window drag 6x "Integer Element" to the left side
  • Close the Elements Window
  • Double click on the "DisplayOLED1" and in the Elements window drag "Draw Text" to the left side and in the properties window set text to "LOTTO" and size to 3
  • In the Elements window also drag "Text Field" to the left side and in the properties window set size to 2 and Y to 30
  • Close the Elements Window

Step 6: In Visuino Connect Components

1 / 3

  • Connect Arduino board digital Out pin [7] to "Button1" pin [In]
  • Connect "Button1" pin [Out] to "Counter1" pin [Reset]
  • Connect "ClockGenerator1' to "Counter1" pin [In]
  • Connect "Counter1" pin [Out] to "RandomIntegerGenerator1" pin [Clock] and "IntegerDemux1" pin [Select]
  • Connect "IntegerDemux1" pin [0] to "FormattedText1' Integer Element1 pin [In]
  • Connect "IntegerDemux1" pin [1] to "FormattedText1' Integer Element2 pin [In]
  • Connect "IntegerDemux1" pin [2] to "FormattedText1' Integer Element3 pin [In]
  • Connect "IntegerDemux1" pin [3] to "FormattedText1' Integer Element4 pin [In]
  • Connect "IntegerDemux1" pin [4] to "FormattedText1' Integer Element5 pin [In]
  • Connect "IntegerDemux1" pin [5] to "FormattedText1' Integer Element6 pin [In]
  • Connect "FormattedText1" pin [Out] to "DisplayOLED1" Text Field1 pin [In]
  • Connect "DisplayOLED1" I2C pin [Out] to Arduino board I2C pin []In

Step 7: 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.

Step 8: Play

If you power the Arduino module, The OLED Display will show the random numbers, if you press the button,a new numbers will be generated.

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...