Computer 3
Computer 3
🔑Key points:
1.Step motor
The third computer also had a step motor. We used the same code as the second computer but the motor didn't work. We thought it was a problem with the motor so we called Kevin.
After he replaced the parts and tightened the screws, he thought it was because our code was too complicated (it should be the wave effect of two LEDs), which affected the motor code.
So we tried to put the motor movement code to the end(🫠 actually we don't know why this could fix the problem...), and it worked, but veeeeery slowly, so we commented it out.
Debugging:
How it work:
📝How to use step motor notes:
Include the Stepper Library: <Stepper.h>.
Define Steps Per Revolution: Match the STEPS_PER_REV to motor's specs.
Set Speed: Use setSpeed() to define RPM.
Rotate: Use step() with positive or negative values to control direction.
Integrate Sensors (Optional): Add conditions like sensor readings to trigger movement.
2.3D print
The 3D printed parts of these two routes need to be hollowed out to allow the LED light strip to pass through.
Especially the plug. The top of one side also needs to be opened to leave room for the magnet sensor.
*At the same time, holes need to be made in the parts so that the wires can pass through. (The original idea was to hang the movable parts)
3.Text Appearing Effect with Particles(Learn from sample code)
Text is converted into an image (PImage) where white pixels represent the desired shape of the text:
PImage p = generateTextImage("test", 240);
Particles are generated at specific pixel positions of the text shape and animated from a start point to their respective positions using easing.
Each particle starts at the center (or another location), moves to an anchor point, and then smoothly transitions to its final position on the text shape.
Create a particle for each visible pixel (not background) in the text image:
ParticleSystem system = new ParticleSystem(p);
Each particle moves based on an easing function (b() in the Particle class).
Animation is achieved by incrementally updating the position using a fraction (f) of the total duration.
Text Update: Dynamically fetch new text via getInputText() and update the ParticleSystem with the new PImage.
Reset Animation: When text changes or is re-triggered, reset all particles to their start positions using resetParticles().
if (showText) {
system.resetParticles(randomStartPoint.x, randomStartPoint.y);