gerardochavez / Ethnic Jade Liquid Breathing Apparatus

Loaded

0

0

Files

Schematic

PCB

Log InSign Up

Arduino Servo Control Code

flux

0:31

Cpp


#include 

Servo servo1;
Servo servo2;

// Posiciones iniciales y objetivo
int pos1 = 0;
int pos2 = 0;
int target1 = 180;
int target2 = 180;

// Velocidades de movimiento (en ms entre pasos)
// Ajusta estos valores para cambiar la velocidad (cuanto mayor el delay, menor la velocidad)
int speed1 = 10; // Velocidad para servo1
int speed2 = 20; // Velocidad para servo2

void setup() {
  // Conecta los servomotores a los pines 9 y 10
  servo1.attach(9);
  servo2.attach(10);

  // Posiciones iniciales
  servo1.write(pos1);
  servo2.write(pos2);
}

void loop() {
  // Mover servo1 hacia target1
  if (pos1  target1) {
    for (int i = pos1; i >= target1; i--) {
      servo1.write(i);
      delay(speed1);
    }
  }
  pos1 = target1;

  // Mover servo2 hacia target2
  if (pos2  target2) {
    for (int i = pos2; i >= target2; i--) {
      servo2.write(i);
      delay(speed2);
    }
  }
  pos2 = target2;

  // Espera un segundo en las posiciones objetivo
  delay(1000);

  // Intercambiar los objetivos para volver a la posición opuesta
  target1 = (target1 == 180) ? 0 : 180;
  target2 = (target2 == 180) ? 0 : 180;
}
Respuesta 1
Respuesta 2
Respuesta 3
414 days

​
Sign up to send

To get started, talk to Flux or create a New Document.

Reviews

Documents

    Documents are markdown text files which describe project goals, capture details, or even simulation outputs.

    Assets

    No assets added.

    Ethnic Jade Liquid Breathing Apparatus

    Ethnic Jade Liquid Breathing Apparatus thumbnail
    Welcome to your new project. Imagine what you can build here.

    Properties

    Properties describe core aspects of the project.

    Pricing & Availability

    Distributor

    Qty 1

    Controls

    Welcome 👋

    Flux helps you build PCBs faster with an AI teammate!

    Create your account to collaborate, stay updated, fork your own version, and get instant answers from our AI agent.

        Introducing AI Placement!
        AI Placement Demo

        AI-Powered Component Placement

        Let AI place your components intelligently. AI Placement analyzes your schematic and positions components for optimal routing, signal integrity, and board density.

        From Schematic to Layout in Seconds

        Skip the tedious manual placement. AI Placement generates a starting layout you can refine, saving hours of repetitive work on every new design.

        Works With Auto-Layout

        Pair AI Placement with Auto-Layout for a complete AI-driven PCB design flow — from component placement through trace routing, all with one click.

        Try it