Computer 2
Computer 2
🔑Key points:
1.3D print
We needed a valve to be installed on the potentiometer, but the model downloaded from the Internet was solid and would take a long time to print, so we learned from Dalin that we could split the model into two, shrink it by 80 percent, and then make it transparent and put it into the original model.
Then dig a hole that will fit the potentiometer.
Hollow Model:
2.Waving LED
Use a loop to light up LEDs in groups (waves)
Adjust brightness for each LED in the wave using CHSV or CRGB (in this case, brightness decreases smoothly within WAVE_LENGTH)
Increment the starting position x in every iteration of the loop()
Wrap around x when it exceeds the total wave pattern length (WAVE_LENGTH + WAVE_SPACING)
Standalone waving LEDs code:
3.Sand canvas
Sand is represented as a 2D array (grid) where each cell contains a value (e.g., color hueValue) or 0 (empty space). Sand particles are rendered as colored rectangles (rect).
Falling logic:
Sand particles move down one cell per frame. If the space below is occupied, they try to move diagonally to the left or right. If all spaces are blocked, the particles stay where they are.
Each cell in the grid with a value > 0 is drawn as a small rectangle (rect). The w variable defines the size of each cell, and the color of the sand changes dynamically using hueValue.
Rendering sand:
This colorMode (HSB) makes the hue transition smoother.
Particles are added on top using addSand() and the grid is updated once per frame. The loop draw() updates the position of the sand using the new nextGrid.
Text Animation: New text fetched from the server triggers an animation (isDown), where the entire grid moves down gradually before resetting.
Grid Reset: The reset() function clears the grid and generates a fresh batch of sand.