Welcome to a digital art project that combines traditional Chinese culture with modern interactive technology! This project, running on the **DFRobot UNIHIKER K10**, displays a screen full of ancient Chinese Copper Coins (*Tian Yuan Di Fang* - Square inside, Circle outside).
Inspired by the density and composition of Yayoi Kusama's "Infinity Nets", the coins are arranged in a mesmerizing, organic pattern. But this isn't just a static imageโit's alive!
Using the onboard sensors, the artwork interacts with the real world:
Blow directly onto the screen (Heat):The temperature sensor detects your breath, causing coins to drop one by one.
Shake the device (Motion):The accelerometer detects the force, causing ALL coins to cascade down rapidly like a sudden windfall of wealth!
Button A:Instantly resets the canvas with a brand new random layout.
It is a perfect festive desktop gadget for Chinese New Year or a fun interactive art piece to show off the capabilities of the K10.
Instead of using bitmap images, every coin is drawn mathematically using the `canvas` API to ensure smooth performance.
1. Outer Circle: Gold filled circle (`canvasCircle`).
2. Inner Square: A square hole drawn in the background color (`canvasRectangle`), representing the ancient philosophy of "Heaven is round, Earth is square".
3. Color Depth: Alternating shades of Gold and Dark Gold to create depth.
The "Yayoi Kusama" LayoutThe coins aren't placed on a strict grid. The algorithm uses:
1. Offset Grid:*Hexagonal/Honeycomb offsets.
2. Perspective Scaling:Coins in the center are larger, while those at the edges are smaller, creating a 3D "fish-eye" effect.
3. Random Jitter:Slight random positions to make it look organic rather than mechanical.
โ๏ธ How It Works (The Code)The logic is divided into three main interaction loops:
1. The Breath Trigger (Temperature)The onboard AHT20 sensor reads the ambient temperature.
```cpp
// Logic for detecting breath
if (current_temp >= next_trigger_temp) {
drop_needed++; // Drop a coin
next_trigger_temp += 0.02; // sensitivity 0.02ยฐC
}
```
When you blow on the sensor, the temperature rises rapidly. The code sets a very sensitive threshold (0.02ยฐC). As the temp climbs, coins start to fall.
2. The "Jackpot" Trigger (Accelerometer)The K10 has a built-in IMU. We monitor the total strength of the G-force.
```cpp
// Logic for shaking
int strength = k10.getStrength();
if (strength > 1250 || strength < 800) {
// Shake detected!
// Set all coins to falling state and double their speed
drop_all_coins(speed * 2);
}
```
A threshold of `1250` ensures that a firm shake triggers the event. The coins drop at **2x speed** for a satisfying visual effect.
3. Anti-Flicker RenderingTo ensure the animation is smooth without flashing (a common issue on MCU screens), we use a specific rendering strategy:
* Instead of `clear()`, we draw a solid background rectangle every frame.
* We limit the total object count to ~80 to maintain high FPS.
---
๐ Usage and Demonstration1. Power On:The device initializes and generates a random "Infinity Net" of gold coins on a festive red background.
2. Gentle Interaction:Blow warm air onto the top-left corner (sensor area). Watch coins drop one by one.
3. Aggressive Interaction:Shake the device hard! Watch the entire screen clear out in a "money rain."
4. Reset:** Press the A Button to refill the screen.
๐ฎ Future Improvements* Add sound effects (coin clinking) when they hit the bottom using the buzzer.
* Add a "score" counter to see how much wealth you collected.







Comments