Random number generator cube on microcircuits. Electronic "cube. Arduino as a phenomenon

This craft implements an electronic version of two standard dice using 14 LEDs, which, when illuminated, form an analogue of two dice and a PIC12F629 microcontroller. As in ordinary non-electronic dice, for example, for playing backgammon, two random and independent values \u200b\u200bfrom 1 to 6 are issued simultaneously. The arrangement of the LEDs is stylized like standard bones.

By pressing the button, within 3 sec. the next combination is issued, then the LEDs go out until the next button is pressed. If the button is not pressed within 15 seconds, the device goes into sleep mode with a current consumption of no more than 1 μA by the tester. By pressing the button again, the operation of the device continues as usual. The device does not have a power switch, it is always ready for use and turns on immediately when the button is pressed. A simple calculation shows that when powered by three cheap salt batteries, the charge will last for 10,000 dice rolls (the average current when the LEDs are lit is 15 mA). And it can be in sleep mode for years ...

Due to the limited number of pins, a dynamic indication is used - each "bone" is ignited within 10 ms alternately with the other. Each "bone" consists of LEDs, arranged in three groups (1, 2 and 4 LEDs), the combination of the glow of which gives all six values. Groups of the same name are connected together and connected to ports GP0 - GP2 of the microcontroller through current limiting resistors R2-R4. All LEDs except D4 and D11 are connected in series in pairs. In the D4, D11 circuit (here not two consecutive, but one LED in a group), diodes VD1 and VD2 are introduced to equalize the brightness of the glow of different groups at a supply voltage of 3.5 - 4.7 V. For the same purpose, the resistance of the resistor R2 is halved (there are two parallel chains of LEDs in the group). The combined cathodes of the LEDs that make up each bone are connected to the GP4 and GP5 ports, respectively. Dynamic indication frequency - 50 Hz. The S1 button is connected to the GP3 input, configured as a normal input.

The randomness of the output values \u200b\u200bis ensured as follows. The TMR1 timer is clocked at 1 MHz, which means it overflows every 0.065 sec. When the button is pressed, the state of the timer is fixed and it is absolutely random due to the subjective nature of the frequency of pressing the button. The value of one "bone" is calculated from the low byte of the timer, and the other from the high byte.

The device is powered by three AA cells, with a voltage of 4.5 V. The LED glow remains bright enough up to a battery voltage of 3.5 V. Due to the high cost and scarcity of stabilizers with their own consumption in microamperes, it was decided to use a direct connection of the device to the battery. This results in some dimming at the end of its life, but allows for ultra-low standby current consumption.

The device is assembled on a printed circuit board measuring 50mm by 60mm.

LEDs are used with a diameter of 3 mm, as they are visually brighter and more like the dots of the dice. VD1, VD2 type КД521. The board provides a place for direct soldering of the clock button. If a remote button is used, it is connected to the board with two pieces of wires.

The source code is written and compiled in the environment. Source code, firmware, project and board drawing are included in the attachment.

P.S. Any blinking on the video is the result of beating the frequencies of the camera and DI. In real life, everything is stable.

List of radioelements

Designation A type Denomination number NoteScoreMy notebook
DD1 MK PIC 8-bit

PIC12F629

1 Into notepad
VD1, VD2 Diode

KD521D

2 KD522 Into notepad
D1-D14 Light-emitting diodeRed 3mm14 Into notepad
R1 Resistor

10 kΩ

1 0.125W Into notepad
R2 Resistor

100 ohm

1 Into notepad
R3 Resistor

200 Ohm

1 Into notepad
R4 Resistor

220 ohm

1

Many games are known in which, for example, the number of points scored by a player. is determined by rolling the dice. It is not difficult to make an electronic "cube" random number generator. Circuits of such generators and descriptions are found in the amateur radio literature.

Recently, the "Age of Battles" game system has gained popularity. Figures of warriors of the most interesting historical eras, siege weapons, elements of terrain and fortresses are produced for it on a scale of 1:72. Now the player can, with a certain amount of historical realism, try himself in the place of Miltiades or some of the Napoleonic marshals.

The rules of the Age of Battle are rather complicated. The probability of many events - hit or miss by an archer, breaking through armor, etc. is determined using a twenty-sided (!) cube. It is difficult to replace it in case of loss or damage. In addition, when the cube is on a soft surface (for example, on a carpet), it becomes not so easy to clearly define its top edge. In addition, the game uses the classic six-sided die for a number of purposes. All this prompted me to develop the design of an electronic "cube" that can work as 20- and 6-sided.

However, the implementation of this seemingly simple task was not easy. The required results were achieved only on the fourth version of the device, which is offered to the readers' attention. I think the design will be interesting and convenient for radio electronics - fans of tabletop battles.

The principle of operation of the device is traditional: a master multivibrator with a frequency of several kilohertz is assembled on elements D1.3, D1.4. When the S1 button is pressed, a high logic level is applied to pin 5 of the D1.2 element, and the multivibrator pulses pass to the D2 counter. When the button is released, the counter stops in some random position, which is indicated. To transfer numbers up to 20, 5 binary digits are required, while most TTL (transistor-transistor logic) counters are four-bit. Therefore, the CMOS chip K176IE2 is used here. This counter is economical, has just 5 bits in the binary counting mode. and moderate performance provides good noise immunity. For reference about the control inputs of the D2 chip. Logic 1 is fed to them. Input E (pin 2) - switch "counting / loading", counting mode is selected. Input 2/10 (pin 1) - switch for binary or decimal counting mode, binary mode is selected.

1 - front panel; 2 - decorative strip; 3 - LED (20 pcs.); 4 - printed circuit board; 5 -Z-shaped bracket for installing the switch (steel plate s1); 6 - fastening the board and the bracket to the body (M3 bolt with nut, 2 sets); S1 - switch; S2 - mode switch

Most of these devices use the classic digital display output. However, it creates a lot of problems, in particular, due to the fact that the account starts from 0, and not from 1, as is customary in game dice. The scheme for selecting count ranges is also cumbersome. Therefore, I had to stop at positional indication. But the applied microcircuit decodes only A binary digits and, accordingly, has 16 output channels. What about the numbers from 17 to 20? The classic solution is to install another decoder is cumbersome and uneconomical, and most importantly, the outputs of the CMOS counter simply will not pull two address inputs of "oak" TTL microcircuits at once. But what if you use the D3 decoder "a second time"? Thanks to the D1.1 element, we have the most significant bit of the address, both in direct and inverse form. Now it is already simple, using transistors VT1, VT2, to turn on the desired group of LEDs. depending on the range of numbers. There are three of these groups: HL 1-6 work at 0 in the fifth binary digit, HL 17-20 - at 1, but HL 7-16 can be powered continuously. The current through the LEDs is determined by the resistors R6, R8, R9. In the device, it is about 7 mA. This provides sufficient brightness of the indication and at the same time does not overload even the low-power TTLSh (transistor-transistor logic with Schottky barrier) K155IDZ microcircuit. When using new generation LEDs on heterostructures, the resistances of these resistors can be doubled or threefold.

The choice of the mode is carried out by switch S2. As soon as the score reaches the "forbidden" 7 or 21 points, a log is sent through R11 to the input of the cascade at VT3. 0. The signal is inverted and the counter reset input is applied. In addition to the logical function, the VT3 cascade performs one more function. The fact is that one of the problems in the joint operation of CMOS and TTL microcircuits is the insufficiently high voltage of the logical 1 of the latter. Here it is amplified almost to the supply voltage. There is one more feature in the operation logic of this node: in the adopted decryption system, the number 21 is “reflected” on the number 5, which can lead to a premature reset of the counter. Therefore, in 20-sided mode, the inverted fifth digit of the counter is fed to VT3 through R10. Due to this, with numbers less than 16, the transistor opens - and at the reset input, the counter will be log 0. regardless of other signals. During the countdown (when the S1 button is pressed), the LEDs of the selected range are slightly backlit by current pulses that "run through" them. This allows you to make sure that the circuit and all LEDs are working properly.

When using a two-mode electronic cube, the following error is possible, working in 6-sided mode, when a 20-sided one is needed. As a result, it may turn out that a powerful ballista will categorically refuse to pierce the armor of the infantrymen. Therefore, an effective 6-sided display is required. No tricks with digital indicators can eliminate the error of distraction. In the proposed design, the 6-sided mode is indicated by the HL7 LED, which is a kind of visual limiter of the included counting range. It is impossible not to notice that instead of one desired one, two LEDs are lit at once, it is impossible, and this is another advantage of the adopted positional display system. In order not to short-circuit the pin to the ground. 7D3, it is separated from the switch by a diode.

A 5V supply voltage stabilizer (DA1 microcircuit) is installed directly on the device board. Due to this, practically any network adapters with an output voltage within 9 - 12 V can be used to power the device, since the current consumption does not exceed 80 mA. An acceptable option is 2 to 3 batteries 336 connected in series. But in this case, it will be necessary to introduce a power switch into the design.

About the details: transistors VT1, VT2 can be any of the series KT361, KT203, VT3 - n-p-n structure, series KT315, KT301, KT312. Chip K176LA7 is replaceable with K561LA7. D3 - 155th or 1533th series. These replacements do not require any PCB wiring changes. Only K1533IDZ can be in a narrower case, but the pinout is the same.

However, it may turn out that the acquisition of the necessary microcircuits will be difficult. Almost all the "logic" sold now in stores - 1988 - 1992. release, and these stocks are running out. It remains to replace the microcircuits with others of a similar purpose. So, as D2, you can use the K176IE1 microcircuit - an unpretentious 6-bit binary counter. As D1 - a microcircuit with three NAND elements. In this case, element D1.2 is excluded, the counting enable signal is connected to one of the inputs D1.3. The good thing about D1.2 is that it also generates pulses from the multivibrator. But the counters will work in such a shortened version of the scheme.

I remind you of the need to follow the rules for installing semiconductor devices: CMOS microcircuits should be stored wrapped in foil, soldered with a low-voltage soldering iron with a grounded tip. This is especially true for microcircuits of early development, when designers were reluctant to install protection elements due to a decrease in performance. In cases of using soldered or suspicious microcircuits, use sockets. LEDs, especially in a plastic case, should be soldered at least 10 mm from the case, preferably with the use of an additional heat sink.

Switch S2 - any with three groups of contacts for changeover. The device under consideration uses 2 P2K buttons with dependent latching. Its pins are shortened on one side. Button S1 - type KM 1-1 or similar. The selection of LED colors (for example, the first 6 are different colors), readers can make at their discretion. Capacitors C3, C4 - any ceramic, suitable in size.

Design. Since the device did not use super technologies such as photolithography and metallization of holes, it was not possible to separate all the conductors by printed wiring. The remaining connections - 3 and 4 digits were soldered with a mounting wire (most conveniently MGTF). On sharply sharpened tweezers, a ring is formed and put on the output of the microcircuit. It remains only to touch it with a soldering iron. Similarly, most of the wires for the LEDs are also soldered directly to the D3 pins, especially since the indicators in the device case are on the foil side.

A radiator made of a small aluminum plate is bolted to the DA1. It is advisable to make ventilation holes in the case opposite it. As for the body and the front panel of the electronic "cube", they are made of boxes cut from the rear plastic wall of the old TV.

The board is located with the parts down and is attached to the case with a rectangular stand and two M3 countersunk screws. This stand, like the S2 mounts, is best made of polystyrene to allow them to be glued to the chassis. After that, a metal bracket with a S1 button is screwed to the board with two nuts. The button is located so that when you press the body, it works.

Make sure there are no gaps or short circuits between tracks. Check the polarity of all LEDs. A device correctly assembled from serviceable parts does not require adjustment. The final check of the correct assembly and functioning of the device can be done very effectively: connect a capacitor with a capacity of about 0.33 μF in parallel to C1. Press S1 If everything is assembled correctly. then you will be able to observe the beautiful effect of running lights in the range selected with switch S2.

The front panel of the device is painted with golden metallic enamel imitating bronze and is stylized as an ancient Greek shield - hoplon.

May Athena Pallas (Greek mythical goddess of war and victory, as well as wisdom, knowledge, arts and crafts) help you in technical creativity and in battle!

A. LISOV. Ivanovo

  • 20.09.2014

    The offered autogenerating SMPS (switching power supply) has small dimensions and high efficiency. Its peculiarity is that the magnetic circuit of the pulse transformer operates with an approach to the saturation region. When designing autogenerating SMPS, in most cases, a powerful transformer is used in a linear mode, and a low-power switching transformer is used in a saturation mode of the magnetic circuit. The individual windings of these ...

  • 17.03.2017

    The circuit of the multivibrator on the NAND elements is shown in Figure 1. The circuit has two states: in one state, the DD1.1 element is closed, and DD1.2 is open, in the other, everything happens the other way around. For example, if the element DD1.1 is closed, DD1.2 is open, while the capacitor C2 is charged with the output current of the element DD1.1, flowing through the resistor R2. Voltage on ...

  • 22.06.2015

    Stationary measuring shunts, interchangeable 75ShIS (hereinafter referred to as shunts), with a nominal voltage drop of 75 mV, are intended to expand the measurement ranges of DC indicating recording devices used at various objects of the defense and security industry. DESCRIPTION Structurally, the shunts are made in the form of manganin jumpers, connected by soldering with brass or copper tips, fixed on a plastic base ...

  • 06.10.2014

    This is a simple signal level indicator for sound reproducing equipment, the circuit is adapted to various user needs. Can be adapted to different input levels - TR1 (input voltage level control), TR2 (gain control). Principle of operation: after amplifying the op-amp on TL017, the signal is rectified by diodes D1-D2 (in the future, only the positive half-wave of the signal is used), then the signal ...

Introduction

I have always wanted to create an electronic, LED dice that is different from other devices available on the Internet. Also, I intended to activate the bone with a shaking motion! Many modern smartphones have a built-in accelerometer that allows you to comfortably play games using dice or dice. The dice moves when you shake your smartphone.

My device will work on the same principle, only without the use of expensive accelerometers.

List of components
Resistor R1 500 Ohm
Resistor R2 500 Ohm
Resistor R3 500 Ohm
Resistor R4 500 Ohm
Resistor R5 500 Ohm
Resistor R6 500 Ohm
Resistor R7 500 Ohm
Resistor R8 10 kOhm
Capacitor C1 100 nF
Flat LEDs 1 to 7.5mm
Piezo Squeaker HPE-120
IC1 PIC microcontroller 16F688 from Microchip
Switch S1 Standard on / off switch

Additional components:
Housing
AAA battery compartment x2
Printed circuit board
Spring, screws and wires
Hex program for loading into the microcontroller

Printed circuit board

This project uses a 31.27mm x 42.25mm single sided PCB.

Top view with components

Bottom view

I used two AAA batteries to supply 3V power to the circuit components and LEDs.

Trigger

A trigger is a mechanical device that responds to shaking motion. One contact is connected to the spring and the other to the conductor. A screw is attached to the end of the spring and acts as a counterweight. When placing the body of the device on the side, the spring has sufficient force not to deform under its own weight. When shaken, the spring moves and comes into contact with the contact that closes the circuit. This is how the microcontroller detects that the dice has been rolled.


Use a small amount of polymorphic material to securely hold the spring. This will give the device a finished look.

Hex program

The program hex code must be written into the microcontroller memory before installing it on the printed circuit board.

The OSC and MCLR fuses must be installed as follows:
INTOSCIO - on
MCLR - off

Testing

Turn on the device. This will initialize the microcontroller and trigger the LEDs.

Shake the body of the device. The LEDs will start blinking like a real die roll. The final number will flash when the piezo speaker beeps. For the next move, simply shake the die again.
https://www.youtube.com/watch?v\u003d4C1OYN87syc&x-yt-ts\u003d1422579428&x-yt-cl\u003d85114404&feature\u003dplayer_embedded
Conclusion

It is an easily repeatable and cheap device. You can use it for many board games.

Bones Is one of the oldest games in the world, dating back millennia. They were originally made from animal bones, and if you believe myths and legends, also human bones, hence their name and a certain mystical aura. Dice were played in Ancient Egypt, Rome, India, from where they penetrated into the Western world with the development of trade and cultural ties. Craps is the most popular type of dice today, played both at home and in casinos, including online casinos. In total, there are several dozen varieties of this game.

The basic principle of the game is simple and clear to everyone - the players throw the dice, the sum of the points dropped on the dice is calculated. Dice themselves are used in a wide variety of board games, forcing you to perform different actions on the map. And, of course, no casino in the world can do without them. However, to play dice, you can use various programs and applications, such as our online dice.

How to roll the dice online?

What if you don't have dice at hand or someone likes to cheat with them? easily solves this problem, because here the computer program throws out the bones, and it is impossible to manipulate the result of its work. The numbers from 1 to 6 drop out randomly.

In addition, our cube simulator is capable of a lot, as we have developed many additional variations of it. In addition to the classic six-sided cube, we have variations of four, eight, ten and even twenty sides that would simply not be possible in real life. And such virtual dice are capable of seriously diversifying ordinary games.

To roll a die online on our website, you need to do three simple steps:

  1. Choose the type of cube - with sides from four to twenty;
  2. Set the number of cubes - from one to twenty;
  3. Click on the "Roll the dice" button.

Online dice have many benefits:

  • - firstly, they will always be at hand, the main thing is to have access to the Internet;
  • - secondly, they do not risk getting lost, rolling under the sofa;
  • - thirdly, they eliminate the risk of fraud, because unlike ordinary cubes that can fall to the edge, they always give an unambiguous result.

The online dice is an amusing entertainment that partly contributes to the development of intuition. With our service, you can roll the dice online with great convenience.