What? Here, for example, dogs are less than a cat, and more than a person. Why not be a fairly large virtual pet that does not fit in any pocket? The microcontroller and the LED matrix (!) In it work from the power supply, and only one real-time clock is from a battery of a larger capacity than all three ordinary Tamagotchi batteries combined. And he "lives" on the table of the author of Instructables under the nickname Syst3mX.
The device on the ATmega328P microcontroller with a bootloader from Arduino. The LED matrix with a resolution of 16x16 (composed of four finished 8x8 matrices) is controlled by four shift registers 74HC595. Two of them are connected to the rows of the matrix through resistors, the other two to its columns through assemblies of composite transistors ULN2803. User interacts with homemade with the help of four buttons. Real-time clock type DS1302 applied. There are two quartz in the circuit: 16 MHz for the microcontroller and 32768 Hz for the clock. Sound signals are provided by a piezoelectric sound emitter.
Throughout electronics the master placed perfboard on one breadboard, LED matrices on another:
Here he installs all the details on the first board:
There is a microcontroller, a power socket, and a real-time clock with a battery in the holder, and shift registers, and transistor assemblies, and a piezoelectric transducer in a makeshift plastic case, and four buttons - two on each side, like an electronic wristwatch, and connectors for comb boards with LED matrices. But all this will not work until Syst3mX connects the components together. So he pulled out the battery, turned the board over, soldered everything according to the diagram, and then returned the battery to its place.
Let's take a closer look at the SMD resistors for LED arrays located on the back of the board:
The master installs the LED matrix on the second board:
She also flips and makes connections, at the same time setting combs. In order not to confuse rows and columns, he uses wires of contrasting colors:
Combs near:
Now you can seal the LEDs with paper and connect the boards together, making sure that the outputs of the components of one board do not touch the conductors of another:
Syst3mX develops a menu structure and icons corresponding to each item:
Then fonts and other images:
With this, you can edit the icons and translate them into a form suitable for copying into a sketch. For which the master is taken:
Done,. Only then rename from TXT to INO. Sketch uses three libraries, but they are all included in the Arduino IDE.The developer flashes a standard Arduino loader into the microcontroller, after which it becomes possible to upload sketches to it with the FTDI adapter as in a regular Arduino. Moreover, both the programmer for the bootloader firmware and the adapter can be made from another Arduino.
The pet dynamically changes five indicators: health, weight, happiness, hunger and age. With it, you can perform four actions: feed, play, wash and treat. Each of the actions positively affects some indicators, but negatively affects others.
You can feed meat, fruits and sweets. Meat best satisfies hunger, but increases weight. Fruits increase health, but reduce happiness (why?), And sweets greatly increase happiness, but reduce health and increase weight.
You can play Simon (a game for storing sequences), played well - happiness increased, badly - decreased.
The pet periodically goes to the toilet, if after that you forget to wash it, your health is lost, and the likelihood of illness increases.
In addition, the likelihood of illness increases with age. The disease can be of three degrees of severity with various side effects, the pet can be treated, but this will reduce his happiness (the developer mistakenly indicated that he was healthy).
From 23:00 to 8:00 the pet is sleeping, while all five indicators do not change in any way. He cannot die in a dream. Sleep time, if it is inconvenient for the user, can be changed in the sketch.