Design autonomous kinematic agents, write real-time Arduino/ESP32 C++ firmware, and simulate multi-actuator robotics with ZeroAI's full-stack ZaiSim engine.
Hardware Loop Rate: 50Hz | Real-Time Ultrasonic Sensor Loop
#include <Servo.h>
Servo steeringServo;
const int trigPin = 9;
const int echoPin = 10;
const int motorLeftPin = 5; // PWM
const int motorRightPin = 6; // PWM
void setup() {
steeringServo.attach(3);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
Serial.begin(115200);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration * 0.0343) / 2; // Current: 42 cm
if (distance < 20) {
// Collision imminent: Turn sharp right
steeringServo.write(45);
analogWrite(motorLeftPin, 200);
analogWrite(motorRightPin, 50);
} else {
steeringServo.write(90);
analogWrite(motorLeftPin, 180);
analogWrite(motorRightPin, 180);
}
delay(50);
}Reference builds — open the ZaiSim workbench and wire up any of these yourself.
4-DOF articulated biped with inverse kinematic gaits and gyro balance stabilization.
Precision robotic arm with forward/inverse kinematics, teach-pendant mode, and vacuum gripper.
8-servo spider bot featuring ripple and wave gaits, ultrasonic obstacle navigation.
Differential-drive rover with 2D LiDAR mapping, PID motor speed control, and encoder feedback.