Control module, which contains the electronic components responsible for controlling the tendon-driven propulsion.
Main body, which houses the control module, tail module, and servo motor.
Tail module, composed of a flexible and elastic structure designed to generate fish-like swimming motion through oscillation.
6. You might need 2*M2 and 4*M3 self-tapping screw.
#include <Servo.h>
const int switchPin = 3; // Switch pin
const int servoPin = 2; // Servo motor pin
Servo myServo;
int center = 84; // Center angle
int swing = 20; // ± range
int currentAngle = center - swing;
int direction = 1;
int mode = 0; // 0 = off, 1 = fast, 2 = medium, 3 = slow
bool lastSwitchState = HIGH;
unsigned long lastDebounceTime = 0;
unsigned long debounceDelay = 150;
void setup() {
pinMode(switchPin, INPUT_PULLUP);
myServo.attach(servoPin);
myServo.write(center);
}
void loop() {
bool currentSwitchState = digitalRead(switchPin);
if (lastSwitchState == HIGH && currentSwitchState == LOW && (millis() - lastDebounceTime > debounceDelay)) {
mode = (mode + 1) % 4; // Cycle through 0 → 1 → 2 → 3 → 0 ...
lastDebounceTime = millis();
}
lastSwitchState = currentSwitchState;
if (mode > 0) {
int servoDelay;
switch (mode) {
case 1: servoDelay = 5; break; // Fast
case 2: servoDelay = 15; break; // Medium
case 3: servoDelay = 30; break; // Slow
}
currentAngle += direction;
myServo.write(currentAngle);
delay(servoDelay);
if (currentAngle >= center + swing || currentAngle <= center - swing) {
direction *= -1;
}
}
}
The Arduino and battery are placed inside the body, while the switches are assembled at the eye positions on both sides. After assembly, the parts are sealed using hot glue or a similar adhesive to ensure a secure and water-resistant finish.
The servo motor is mounted onto the PRT_TAIL part using M3 bolts (4–6 mm length). After securing the motor, the prt_under_body component is attached, followed by assembling the servo output arm. Finally, the PRT_TAIL and prt_under_body parts should be fixed together using glue for a firm hold.
The PU rods are inserted through PRT_TAIL_2, PRT_TAIL_3, and PRT_TAIL_4 in sequence to form the flexible tail structure. Two PRT_TAIL_end parts are then joined together using adhesive to enclose the end of the tail. Make sure each part is aligned properly before applying glue to secure the joints firmly.
The final assembly consists of three main components: the control module, the main body, and the tail module. The control module is attached on top of the main body, which houses the servo motor and electronics. The tail module, including the PU rods and flexible segments, is connected to the rear of the main body. All modules should be properly aligned and securely bonded using adhesive to ensure stable operation and water resistance. If needed, a stabilizer fin can be added to the bottom of the main body for improved swimming stability.